计算字符串长度

(function(){
	function getCharlen(s){
		return Function('return '+s.split('').map(function(e){return e.charCodeAt(0)<256?1:2}).join("+"))()
	}

	console.log(getCharlen('123中文abc'));//10
})();

 

posted @ 2017-06-01 15:29  叮了个嘣  阅读(191)  评论(0)    收藏  举报