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

前端 未结 10 1585
鱼传尺愫
鱼传尺愫 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:15

    just randomly generate some strings:

    function getUID(len){
        var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
              out = '';
    
        for(var i=0, clen=chars.length; i

提交回复
热议问题