const now = Temporal.Now.plainDateTimeISO()
const timeUntil5pm = 17 - now.hour
Temporal.PlainDateTime.add(now, { hours: timeUntil5pm })
console.log(`Time until 5pm: ${timeUntil5pm} hours`)
Promise.resolve().then(() => console.log('Promise resolved'))
console.log('Main thread finished')Main thread finished Promise resolved Time until 5pm: output depends on current time
Explanation: This code first calculates the time until 5pm and logs it. Then it creates a promise that resolves immediately and logs 'Promise resolved' when resolved. Because promises are asynchronous and use the event loop, 'Main thread finished' is logged before 'Promise resolved'. The order of 'Time until 5pm' and other logs can vary because its calculation depends on the current time which can affect the order of operations in the event loop.
Key Insight: JavaScript Event Loop, asynchronous operations, and Temporal API usage.