||
is the logical OR
.
The expression
var x = x OR {};
should become more obvious then.
If x
has a falsy value (like null
, undefined
, 0
, ""
), we assign x
an empty object {}
, otherwise just keep the current value. The long version of this would look like
var x = x ? x : {};