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 :: mongoose post new document 
Javascript :: tabindex 
Javascript :: discord.js dm 
Javascript :: online python to c++ converter 
Javascript :: js append sample 
Javascript :: Pausing setInterval when page/ browser is out of focus 
Javascript :: nodejs process object 
Javascript :: Mutations 
Javascript :: Make a ReactNative component take the height and width of the current window 
Javascript :: poo javascript heritage 
Javascript :: how to Initialize and fill an array with the specified values in javascript 
Javascript :: jquery database add dropdown in datababe grid 
Javascript :: moment iso string to zero 
Javascript :: vite esbuild configuration 
Javascript :: import all var js 
Javascript :: remember previous window javascript 
Javascript :: express plus es5 
Javascript :: anonymous functions 
Javascript :: how to apply multiple attributes using js 
Javascript :: discord.js get message content 
Javascript :: mongoose connecting directly rather than tunnel 
Javascript :: can not found jstl core xml file 
Javascript :: reverse linklist in javascript 
Javascript :: why typescript is superset of javascript 
Javascript :: json serializable snake case 
Javascript :: nodejs post req accept form data 
Javascript :: jit and aot 
Javascript :: how to print 1 to n numbers without using loop javascript 
Javascript :: Example of Logical OR assignment operator in es12 
Javascript :: ngFor fake 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =