I need to get unique random number in javascript (or Typescript).
At this moment I use this code:
var id = -((new Date()).getTime() & 0xffff);
It returns me numbers like -13915
or -28806
...
It works most of the time but I am having problems when this code is executed in promises (so nearly multiple times at the same time). Then sometimes I got two identical id.
Is there any solution to get unique random numbers in any case ?