I use (Math.random()*1e32).toString(36)
as a simple random string generator. It is very simple and works well and fullfils my needs (a temporal random to be used for ids, etc)
In chrome, safari, firefox and ie Math.random()*1e32
generates numbers like: 8.357963780872523e+31
:-)
- In chrome, safari and firefox such number is converted into a string
(8.357963780872523e+31).toString(36)
->221fr2y11ebk4cog84wok
which is exactly I want. - However in ie11 the string result is
6.936gwtrpf69(e+20)
.
How can I get the same string 221fr2y11ebk4cog84wok
from 8.357963780872523e+31
in a cross browser manner?
BTW: I got the idea of this random string from this thread: Random alpha-numeric string in JavaScript?