Last active
August 29, 2015 14:04
-
-
Save CooLNuanfeng/455ca4912eeb3f5b9e9c to your computer and use it in GitHub Desktop.
生成随机字符串(0~9,a~z)
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
/** | |
* @function:generateRandomAlphaNum->生成随机的字符串 | |
* @param:len->生存随机字符串的长度 | |
* @tdd->IE6-9 chrome Firefox通过测试 | |
* | |
*/ | |
function generateRandomAlphaNum(len) { | |
var rdmString = ""; | |
//toSting接受的参数表示进制,默认为10进制。36进制为0-9 a-z | |
for (var i=0; rdmString.length < len; rdmString += Math.random().toString(36).substr(2)); | |
return rdmString.substr(0, len); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment