var str ="Rome was not built in a day"; var arr =str.split("");//去掉所有的空格 document.write("字符串的长度:"+arr.length);