Generate random string/characters in JavaScript

前端 未结 30 1772
闹比i
闹比i 2020-11-21 06:34

I want a 5 character string composed of characters picked randomly from the set [a-zA-Z0-9].

What\'s the best way to do this with JavaScript?

30条回答
  •  感情败类
    2020-11-21 07:15

    How about something like this: Date.now().toString(36) Not very random, but short and quite unique every time you call it.

提交回复
热议问题