This is not true. In JavaScript, there is no block region, only a function region * . All variables entered into the function rise to the top of the function.
So this code:
function prepForDrag(obj, event) {
if (event = "undefined") {
var event = obj || window.event;
}
}
interpreted as follows:
function prepForDrag(obj, event) {
if (event = "undefined") {
event = obj || window.event;
}
}
, event , event , . , JavaScript Scoping and Hoisting.
.
, . ? obj -, event? , . , :
function prepForDrag(e) {
var event = e || window.event;
}
* NB: let statement, JavaScript 1.7, , Firefox.