This question already has an answer here:
-
*
/questions/29667199/hoisted-javascript-variables
/questions/29667199/hoisted-javascript-variables
4 answers
Answers
If I move the declaration of printToConsole above the call to _.each then it works fine.
printToConsole appear to be an anonymous function expression , not a function declaration ; printToConsole is not defined when _.each is called . Try defining printToConsole as a function declaration , or as noted, adjust placement to above call to ._each
Source
License : cc by-sa 3.0
http://stackoverflow.com/questions/31221950/javascript-and-hoisted-functions