Possible Duplicate:
What does this construct (x = x || y) mean?
a lot of times i can see that variables set like that
var d = d || {}
or
var = var || []
a few question came up to mind
- what it’s mainly purpose ?
- how can it be to use OR in variable define?
The
||operator returns the left hand side if it is true and the right hand side if the left hand side isn’t true.So:
Is a quick way of saying: