samedi 31 janvier 2015

Javascript - How are things broken?



var myName = 4;

function myName() {
console.log("xxxx");
}
console.log(typeof myName); //Number

var myNamex;

function myNamex() {
console.log("xxxx");
}
console.log(typeof myNamex); //function


Please refer the fiddle - http://ift.tt/1tLtinZ



console.log(typeof myName);


The above log statement logs different value, the only difference is that the variable is assigned a value in one place, and not in another.


Can you tell me how are both code snippet broken down, considering hoisting, closure or any that can be applied.





Aucun commentaire:

Enregistrer un commentaire