Let's take this code:
{ a: Date.now(), b: Date.now() }
It returns: { a: 1664294035466, b: 1664294035466 }
Can I be sure that the keys a
and b
will always have the same value?
CodePudding user response:
No, you cannot. Date.now
returns the current time at the exact moment it is called. This code will call it twice, and it's possible (with luck) that the timer ticks over to the next millisecond in between the calls.