JavaScript Methods | interactive
☰
back to String methods
JavaScript String
length property
returns the length of a string
length property returns the length of a string.
length property does not accept any parameter.
length data property of a String value contains the length of the string in UTF-16 code units.
length property of an empty string is 0
Because string is a primitive, attempting to assign a value to a string's length property has no observable effect, and will throw TypeError in strict mode.
syntax description
return the length of myString
↴
myString.length