JS求字符串长度

 1 function getBytes(str){
 2     var len = str.length;
 3     var bytes = len;
 4     for (var i=0; i<len; i++){
 5         if(str.charCodeAt[i] > 255) bytes++;
 6     }
 7     return bytes;
 8 }
 9 
10 alert(getBytes());
原文地址:https://www.cnblogs.com/Yanss/p/12764616.html