SOURCE

var str ="Rome was not built in a day";
arr =str.replace(/\s/g);//去掉所有的空格
var length =0;
for(var i of str)
{
length++;
}
document.write("字符串的长度为");
document.write(length);
console 命令行工具 X clear

                    
>
console