It's not pretty common. But, if you ever encounter such code, be sure it's a very bad practice. Introducing more scopes is a performance issue for JavaScript interpreter. It adds a new scope in the ladder. See the following sample scope:
function pageLoad()
{
scope1();
function scope1()
{
alert('scope1');
scope2();
function scope2()
{
alert('scope2');
}
}
}
Introducing more scopes enforces the interpreter to go through new more sections in the scope chain that it maintains for code execution. So, unnecessary scopes reduce performance and it's a bad design too.
No comments:
Post a Comment