Skip to content

Instantly share code, notes, and snippets.

@alanland
Created August 15, 2013 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanland/6238778 to your computer and use it in GitHub Desktop.
Save alanland/6238778 to your computer and use it in GitHub Desktop.
JS 基础类扩展
// 计算长度,中文当作两个长度
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