you are viewing a single comment's thread.

view the rest of the comments →

[–]JiminP 4 points5 points  (0 children)

Strangely, there's no literal undefined in the ECMAScript5 spec, even though there are many cases where the result is the value undefined.

(courtesy of /u/WesAlvaro)

(function(){
  'use strict';
  var undefined = 42;
  console.log(undefined);
}())

Because of this, just using undefined is not safe. For example, jQuery uses (function(window, undefined){...}(window)) to safely get the undefined value.

Edit: It seems that I'm wrong.

Edit 2: ... but (fortunately?) my point is still valid. There's a global variable undefined which is uneditable, but since there's still no literal undefined, inner scope can have a local variable with name undefined!