The Length of a String
Accessing a String's Length
All strings have a length. A string's length equals the number of characters in the string. You can access a string's length by using its length property. To access the length of a string, we use dot notation. Dot notation uses a dot/period to access properties on certain data structures. If you want to find the length of the string 'I like puppies', you would first type the string, then a dot/period, and finally, the name of the property you want to access, which would be length in this case. Check out the code snippet below to see how to use dot notation to access the length of the string 'I like puppies':
'I like puppies'.length;
The code 'I like puppies'.length; will return the number 14. All characters inside of the string are counted in the string's length. This includes letters, numbers, spaces, punctuation, and symbols.