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: flag(); function flag() { console.log('flag'); } const anotherFlag = () => { console.log('another flag'); } anotherFlag(); What is result of the code block?
Correct Answer: D
Key points: Function declarations are hoisted (their definitions are available before the line where they appear). Function expressions assigned to const or let are not hoisted as callable functions, but here anotherFlag is only used after it is defined. Step-by-step: flag(); at the top: flag is a function declaration defined later; due to hoisting, it is available. It logs 'flag'. The declaration: function flag() { console.log('flag'); } is already in effect (hoisted before execution). const anotherFlag = () => { console.log('another flag'); } defines anotherFlag as an arrow function. anotherFlag(); is called after its definition; this is valid and logs 'another flag'. No errors occur. The console output is: flag another flag So option D is correct. Concepts: function hoisting, difference between function declarations and function expressions, execution order.