Example:
ouch(); //"TypeError: ouch is not a function
var ouch= function(){
console.log("ouch");
};
the code above cannot work, because the function ouch is declared after calling. while in another way. we bind ouch function in a click callback, then it can work!
$("#btn").click(function(){
ouch(); // "ouch"
});
var ouch= function(){
console.log("ouch");
};
Can you explain why we can call ouch like this. Is ouch already been declared and assigned. If so, when does the engine make the declared and assigned?