Date.now()

Date.now()

Under the covers, the Date object keeps track of time as the number of milliseconds since January 1st, 1970. (This value is also known as a timestamp.) Date.now() is a simple way to get this value without having to first create a Date object.

Here's an example program that keeps track of how long it takes for you to press the button.