Inside your hoisting
function the code gets reordered as follows:
function hoisting(){
var mysecondmethod;
function mymethod(){
alert("local mymethod");
}
alert(typeof mymethod);
alert(typeof mysecondmethod);
mymethod();
mysecondmethod();
mysecondmethod = function() {
alert("local mysecondmethod");
};
}
Here it is pretty obvious, that you create a new variable mysecondmethod
inside the function's scope, which overlays your outside definition.
At the point of the call of the function, however, it is not defined (yet) and thus you get your errors.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…