ES6 - String length property



This property returns the number of characters in a string.

Syntax

string.length

Example: String constructor property

var uname = new String("Hello World")
console.log(uname)
console.log("Length "+uname.length) // returns the total number of characters // including whitespace

Output

Hello World
Length 11
Advertisements