0

Why the answer is "b"?

a(); function a(){ console.log("b"); }

28th Dec 2017, 7:17 AM
john arnold barrozo
john arnold barrozo - avatar
2 Answers
+ 10
This behavior is due to something called "hoisting". JavaScript moves ("hoists") all declarations to the top of the file before executing the code. This applies to function definitions and variable declarations. For further info, see https://www.w3schools.com/js/js_hoisting.asp
28th Dec 2017, 2:59 PM
Eric Blinkidu
Eric Blinkidu - avatar
+ 5
because JavaScript is less concerned in the other of which your functions are called so when the function is called it consoles "b"
28th Dec 2017, 7:18 AM
᠌᠌Code X
᠌᠌Code X - avatar