Yavor Atanasov web portfolio

Weblog

2012
04.05

Although already introduced features of ECMAScript5 fix this, the global property undefined in older versions of JavaScript is writable just like any other property. This means someone can override it which can cause trouble in a shared environment where everyone assumes its value.

undefined = "not undefined anymore";
(function(arg1, arg2, undefined){

    // undefined is undefined in here

})(value1, value2);

This creates a locally scoped variable undefined that has the value of undefined (more on the type, value and variable undefined here). This way your code does not rely on the “fragile” global undefined and is more robust.
More info:

No Comment.

Add Your Comment

Your Comment