Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

uuid generator pure javascript

function uuid(mask = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx') {
    return `${mask}`.replace(/[xy]/g, function(c) {
        var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
        return v.toString(16);
    });
}

console.log(uuid('PREFIX-xxxx-xxxx-xxxx-xxx-SUFIX'))
// adapted by iury.landin
Comment

javascript generate uuid

const generateUuid = (): string => {
    return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (character) => {
        const random = (Math.random() * 16) | 0;
        const value = character === "x" ? random : (random & 0x3) | 0x8;

        return value.toString(16);
    });
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: array of A-Z 
Javascript :: js check if element into view 
Javascript :: jquery get element id 
Javascript :: javascript length of object 
Javascript :: js stop form submit 
Javascript :: ejs comments 
Javascript :: countup on scroll react only once 
Javascript :: angular ng serve with custom port 
Javascript :: angular moment 
Javascript :: js input trigger change event when set value with js 
Javascript :: javascript regex email 
Javascript :: javascript get all array elements except last 
Javascript :: ng update angular material 
Javascript :: document.addEventListener("load", function () { 
Javascript :: puppeteer how to serch for text 
Javascript :: jquery ajax post form 
Javascript :: check undefined object javascript one liner set to emtpy 
Javascript :: how to sort by newest document mongoose 
Javascript :: pass number as a prop in react 
Javascript :: readable date in javascript 
Javascript :: canvas font colour 
Javascript :: separate digits in javascript 
Javascript :: react dom 
Javascript :: generates a random rgb color number. 
Javascript :: js canvas draw polygon 
Javascript :: javascript remove element by id 
Javascript :: preview image file upload javascript 
Javascript :: discord javascript error cannot find module 
Javascript :: how to do text to speech in javascript 
Javascript :: node print stdin 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =