Tuesday, November 11, 2025

 



In JavaScript, when you compare objects using == or ===, you're comparing their references in memory, not their actual contents. Even if two objects have the same properties and values, they are considered unequal unless they reference the exact same object in memory.





    Start, End,Promise,Timeout.
  • 'Start' is logged first because it's a synchronous operation.
  • Then, 'End' is logged because it's another synchronous operation.
  • 'Promise' is logged because Promise.resolve().then() is a microtask and will be executed before the next tick of the event loop.
  • Finally, 'Timeout' is logged. Even though it's a setTimeout with a delay of 0 milliseconds, it's still a macrotask and will be executed in the next tick of the event loop after all microtasks have been executed.

Use let instead of var to get block-scoped behavior:































No comments:

Post a Comment