The length
property returns the number of characters in a string. The functionality of length
is shown in the illustration below:
The length
property is declared as follows:
The length
property does not take any parameters.
The length
property returns the length of the string as an integer
number. If the string is empty, zero is returned.
The following code shows the use of the length
property in JavaScript:
//Example 1str = "Hello";console.log(str.length);//Example 2str2 = "";console.log(str2.length);
Free Resources