Nope, the order in which names are defined when entering an execution scope is as follows:
- function parameters (with value passed or
undefined)
- special name
arguments (with value of arguments if doesn't exist)
- function declarations (with body brought along)
- variable declarations (with
undefined if doesn't exist)
- name of current function (with body brought along, if doesn't exist)
This means that in this code, foo refers to the function parameter (which could easily be changed):
function foo(foo) {
var foo;
alert(foo);
}
foo(1); // 1
If you're using a function declaration inside for foo, that body will override all others. Also, note that this means that you can do this:
function foo(arguments) {
alert(arguments);
}
foo(); // undefined
foo(1); // 1
Don't do that.