Valid JS-Dev-101 Dumps shared by EduDump.com for Helping Passing JS-Dev-101 Exam! EduDump.com now offer the newest JS-Dev-101 exam dumps, the EduDump.com JS-Dev-101 exam questions have been updated and answers have been corrected get the newest EduDump.com JS-Dev-101 dumps with Test Engine here:
Refer to the code below: 01 let sayHello = () => { 02 console.log('Hello, World!'); 03 }; Which code executes sayHello once, two minutes from now?
Correct Answer: B
________________________________________ Comprehensive and Detailed Explanation From Exact Extract JavaScript Knowledge To schedule a function for later execution in JavaScript, the standard built-in method is: setTimeout(functionReference, delayInMilliseconds) Characteristics of setTimeout(): Executes only once. Delay is specified in milliseconds. Requires passing the function reference, not calling the function. Two minutes is: 2 minutes = 120 seconds = 120,000 milliseconds Now evaluate each option: ________________________________________ Option A: delay(sayHello, 120000); Incorrect. There is no built-in delay() function in JavaScript. ________________________________________ Option B: setTimeout(sayHello, 120000); Correct. sayHello is passed as a function reference, so it will execute once after 120,000 ms. ________________________________________ Option C: setTimeout(sayHello(), 120000); Incorrect. sayHello() calls the function immediately, and the return value (undefined) is passed to setTimeout. This executes the function right away instead of after two minutes. ________________________________________ Option D: setInterval(sayHello, 120000); Incorrect. setInterval() repeats execution every 120,000 ms. The question requires executing the function once, so this cannot be correct. ________________________________________ JavaScript Knowledge Reference (text-only) setTimeout() schedules a function to run once after a specified delay. Passing functionName gives a reference; passing functionName() invokes it immediately. setInterval() repeats indefinitely, unlike setTimeout().