Skip to content

Instantly share code, notes, and snippets.

@Nesuarg
Last active July 2, 2019 07:24
Show Gist options
  • Save Nesuarg/f349c217b6a853f32f7baacb2b99bd85 to your computer and use it in GitHub Desktop.
Save Nesuarg/f349c217b6a853f32f7baacb2b99bd85 to your computer and use it in GitHub Desktop.
globally unique identifier in Javascript
function unique() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}
// usage
var guid = (unique() + unique() + "-" + unique() + "-4" + unique().substr(0,3) + "-" + unique() + "-" + unique() + unique() + unique()).toLowerCase();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment