Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

uuid javascript

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

var userID=uuid();//something like: "ec0c22fa-f909-48da-92cb-db17ecdb91c5" 
Comment

uuid javascript

    function uuid() {
        const template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
        const xAndYOnly = /[xy]/g;

        return template.replace(xAndYOnly, (character) => {
            const randomNo =  Math.floor(Math.random() * 16);
            const newValue = character === 'x' ? randomNo : (randomNo & 0x3) | 0x8;

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

uuid in node js

const {v4 : uuidv4} = require('uuid')
Comment

PREVIOUS NEXT
Code Example
Javascript :: js replace all spaces 
Javascript :: js union arrays 
Javascript :: page reload button using angular 
Javascript :: iterate array javascript 
Javascript :: set datetimepicker javascript 
Javascript :: javascript check date greater than today 
Javascript :: javascript format number with commas 
Javascript :: change list of objects to list js 
Javascript :: joi enum validation 
Javascript :: check if a class exists javascript 
Javascript :: javascript redirect to another page 
Javascript :: redirect browser javascript 
Javascript :: display none javascript 
Javascript :: javascript countdown 10 seconds 
Javascript :: jquery datepicker set default date 
Javascript :: java superscript numbers 
Javascript :: console log state object redux 
Javascript :: how to find factorial of a number using Recursion in javascript 
Javascript :: react native heroicons 
Javascript :: remove null and undefined from array 
Javascript :: disable unused vars 
Javascript :: js decode base64 
Javascript :: js not equal to null 
Javascript :: httpget javascript 
Javascript :: check box all in jequery data table 
Javascript :: react-native android 
Javascript :: javascript open new window 
Javascript :: how to validate age above 18 in javascript 
Javascript :: js select and copy on click 
Javascript :: get the last item in object javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =