Strings
Strings
A string stores a sequence of characters — including letters, numbers, spaces, and punctuation. Strings are enclosed in single (') or double (") quotes, and the quotes themselves are not part of the stored value. In both JavaScript and Python, string indexing is zero-based.
JavaScript:
var robot = 'Ollie';
var report = "Wow! Ollie just did a 720 in mid-air!";
Python:
robot = 'Ollie'
report = "Wow! Ollie just did a 720 in mid-air!"
Get Length returns the length of a string:
JavaScript: str.length
Python: len(str)
Constructor returns the string's constructor function:
JavaScript: str.constructor
Python: type(str)
Prototype extension allows you to add properties and methods to an object:
JavaScript: String.prototype.method
Python: Not applicable