Strings are immutable: Strings cannot be changed, only replaced. All string methods return a new string. They don't modify the original string.
text.length
The length
property returns the length of a string.
let text = "Kitten sings a song."; let length = text.length; // 20
text.constructor
The constructor
property returns the function that created the String prototype.
For strings, it returns: function String() { [native code] }
.
let message = "Hello World!"; let text = message.constructor; text; // ƒ String() { [native code] }
object.prototype
.name = valueThe prototype
is a property available with all JavaScript objects. The prototype property allows you to add new properties and methods to strings.
Warning
function Person(first, last, age, eyecolor) { this.firstName = first; this.lastName = last; this.eyeColor = eyecolor; } Person.prototype.nationality = "English";