I just want to increase my core javascript knowledge.
Sometimes I see this statement but I don\'t know what it does:
var var1 = var1 || [];
The || operator evaluates the first of its operands that is "truthy".
||
[] is an empty array. ([ "Hi!" ] is an array of one string)
[]
[ "Hi!" ]
Therefore, the expression x || [] evaluates to x if it's "truthy" or an empty array if it isn't.
x || []
x
This allows the var1 parameter to be optional.
var1