JS-Dev-101 practice question 24 of 25
Refer to the code below: 01 let sayHello = () => { 02 console.log('Hello, World!'); 03 }; Which code executes sayHello once, two minutes from now?
Full set: 148 questionsThe browser timer API specifies setTimeout(callback, delay) to invoke the callback once after the delay (in milliseconds). Passing the function reference and 120 000 ms (2 minutes) therefore schedules a single execution of sayHello exactly once after two minutes.
A. delay() is not a standard timer API; undefined in browsers.
C. sayHello() immediately executes and the return value (undefined) is given to setTimeout, so nothing runs later.
D. setInterval repeats the call every 120 000 ms instead of running it only once.
1. WHATWG HTML Standard, §8.6.1 “Timers”, Definition of setTimeout(callback, delay).
2. Mozilla Developer Network (MDN) – setTimeout, “callback is executed once after delay”.
Keep practicing
Take the free JS-Dev-101 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other JS-Dev-101 practice questions
- Question 1A developer executes: document.cookie; document.cookie = 'key=John Smith'; What is the be…
- Question 2A developer is required to write a function that calculates the sum of elements in an arr…
- Question 3Given the code below: 01 const delay = async delay => { 02 return new Promise((resolve, r…
- Question 401 function Animal(size, type) { 02 this.type = type || 'Animal'; 03 this.canTalk = false…
- Question 5Refer to the code snippet: 01 let array = [1, 2, 3, 4, 4, 5, 4, 4]; 02 for (let i = 0; i …
- Question 6Code: 01 let array = [1, 2, 3, 4, 4, 5, 4, 4]; 02 for (let i = 0; i < array.length; i++) …
