SOURCE

var str ="Rome was not built in a day";
arr =str.replace(/\s/g);
var num =0;
for(var i of str)
{
num++;
}
document.write(num);
console 命令行工具 X clear

                    
>
console