π Prefer Date.now() to get the number of milliseconds since the Unix Epoch.
πΌ This rule is enabled in the following configs: β
recommended, βοΈ unopinionated.
π§ This rule is automatically fixable by the --fix CLI option.
Date.now() is shorter and nicer than new Date().getTime(), and avoids unnecessary instantiation of Date objects.
// β
const foo = new Date().getTime();
// β
const foo = new Date().valueOf();
// β
const foo = +new Date;
// β
const foo = Number(new Date());
// β
const foo = Date.now();// β
const foo = new Date() * 2;
// β
const foo = Date.now() * 2;