length property
The length property allows you
to find out the length of a string. The
length is the number of characters in a
the string.
Syntax
string.length;
Example
Let the variable str
store a string. Let's find
its length:
let str = 'abcde';
console.log(str.length);
The code execution result:
5
Example
The length of a string also includes spaces. Let's find the length of the string that has a space:
let str = 'word1 word2';
console.log(str.length);
The code execution result:
11