Please compare:
// Version 1
const oneHour = 60 * 60
function checkTime(timePast) {
if (timePast<7 * 24 * oneHour) {
// Do something
}
}
// Version 2
const oneHour = 60 * 60
const oneWeek = 7 * 24 * oneHour
function checkTime(timePast) {
if (timePast<oneWeek) {
// Do something
}
}
During millions of calls to checkTime(), is version 2 faster than version 1, or is Node.js smart enough to make the extra calculation in version 1 only once?