Skip to content

Instantly share code, notes, and snippets.

@c0derabbit c0derabbit/unique_id.js

Last active Sep 30, 2017
Embed
What would you like to do?
Creates a unique ID in JavaScript
const id = Date.now() + Math.random().toString(16).substr(2);

unique_id.js

Returns a unique alphanumeric ID given that it uses Date.now() and a random string.

Usage

Create and use the id any time.

var yourNewId = Date.now()+Math.random().toString(16).substr(2);
var yourOtherNewId = Date.now()+Math.random().toString(16).substr(2);

yourNewId and yourOtherNewId will look something like this, but of course, both completely unique: "146849867772717a4cb2f"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.