Last active
July 30, 2019 15:34
-
-
Save waimyokyaw/6e5d24a5108633a0592c76148e67c0b9 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
function guid(len) { | |
var buf = [], | |
chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', | |
charlen = chars.length, | |
length = len || 32; | |
for (var i = 0; i < length; i++) { | |
buf[i] = chars.charAt(Math.floor(Math.random() * charlen)); | |
} | |
return buf.join(''); | |
} | |
console.log(guid()); | |
console.log(guid(15)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment