Created
July 28, 2015 08:37
-
-
Save laispace/f349c466198dcd2becb2 to your computer and use it in GitHub Desktop.
判断字符是否为英文
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
/** | |
* 判断置顶字符是否为英文 | |
* @method isEnglish | |
* @param {String} s | |
* @return {Boolean} | |
*/ | |
isEnglish: function(s) { | |
var code = ('' + s).charCodeAt(0); | |
if (code >= 0x0041 && code <= 0x005A || code >= 0x0061 && code <= 0x007A) { | |
return true; | |
} else { | |
return false; | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment