How to generate short uid like “aX4j9Z” (in JS)

前端 未结 10 1576
鱼传尺愫
鱼传尺愫 2020-12-12 14:47

For my web application (in JavaScript) I want to generate short guids (for different objects - that are actually different types - strings and arrays of strings)

I w

10条回答
  •  春和景丽
    2020-12-12 15:34

    Here is a one liner, but it gives only lowercase letters and numbers:

    var uuid = Math.random().toString(36).slice(-6);
    
    console.log(uuid);

提交回复
热议问题