I want to define a variable to default value if not already defined but found a strange issue.
var x = x || {}
works whereas x = x || {}
gives an error.
Output from firebug.
>>> a = a || {};
ReferenceError: a is not defined
[Break On This Error]
a = a || {};
with(_... {}; }; (line 2)
>>> var b = b || {};
undefined
>>> b;
Object {}
>>> a;
ReferenceError: a is not defined
[Break On This Error]
why does the first one give error while the second seems to go through.