Skip to content

Interesting Browser APIs

Paul "Joey" Clark edited this page Jun 7, 2018 · 1 revision

Time and Date

You can use Date.now() to get the number of milliseconds since 1970.

But if you are going to perform an arithmetic operation, using new Date%9 will be shorter. (That will produce a randomish number between 0 and 8 inclusive, although the randomness is not very strong, and differs between browsers.)