Code QuizAdvanced

Microtasks run before setTimeout callbacks

Promise callbacks (microtasks) always run before setTimeout callbacks (macrotasks), even with a 0ms delay.

Codejavascript
let data = null;

setTimeout(() => {
  data = 'loaded';
}, 0);

Promise.resolve().then(() => {
  // expected to print 'LOADED'
  console.log(data.toUpperCase());
});

What is the bug in this code?