Created
August 15, 2013 06:45
-
-
Save alanland/6238778 to your computer and use it in GitHub Desktop.
JS 基础类扩展
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 计算长度,中文当作两个长度 | |
String.prototype.len = function () {return this.replace(/[^\x00-\xff]/g, "**").length}; | |
"哈哈asd哈哈".len(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment