1

When I execute this code:

var a = {
    b: Date.now(),
    c: Date.now(),
    d: Date.now(),
}
console.log(a);

My console shows me that the milliseconds since 1970 for the b, c and d keys of a are the same.

Does this mean that these three keys are all assigned in less than a millisecond? Or is the javascript interpreter just calculating it once and assigning it to all keys?

1 Answer 1

2

Those three keys are all assigned in less than a millisecond. Simple operations are done immediately and there is no difference you can see in ms. To see a bigger difference you can check it eg. by doing some stress-test like generating random 100.000.000 times in a loop and set time before and after loop.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.