无涯教程-length函数

49 阅读1分钟

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

length - 语法

string.length

length - 示例

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 

参考链接

www.learnfk.com/es6/es6-str…