Pattern: Timestamp creation via new Date()
Issue: -
Using Date.now()
is more concise and efficient than new Date().getTime()
or new Date().valueOf()
as it avoids creating unnecessary Date
objects.
Example of incorrect code:
const ts = new Date().getTime();
const ts = new Date().valueOf();
Example of correct code:
const ts = Date.now();