Published On: February 12th, 2023Categories: AI News



Q1. How is a forEach statement different from a for statement?

  1. Only a for statement uses a callback function.

  2. A for statement is generic, but a forEach statement can be used only with an array.

  3. Only a forEach statement lets you specify your own iterator.

  4. A forEach statement is generic, but a for statement can be used only with an array.

Answer

2

Reference Differences between forEach and for loop




Q2. When would the final statement in the code shown be logged to the console? When would ‘results shown’ be logged to the console?

let modal = document.querySelector('#result');
setTimeout(function () {
  modal.classList.remove('hidden');
}, 10000);
console.log('Results shown');
Enter fullscreen mode

Exit fullscreen mode

  1. after 10 second
  2. after results are received from the HTTP request
  3. after 10000 seconds
  4. immediately
Answer

4

Reference Javascript is synchronous and single threaded




Source link

Leave A Comment