Length


此属性返回字符串中的字符数。

语法

string.length

示例:String构造函数属性

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

输出

Hello World
Length 11