From the google analytics tracking code:
var _gaq = _gaq || [];
how does this work?
Is it a conditional variable value assignment? Is it the same as saying:
if( !(_gaq) ) {_gaq = []; }
?
The or operator (||
) will return the left hand side if it is a true value, otherwise it will return the right hand side.
It is very similar to your second example, but since it makes use of the var
keyword, it also establishes a local scope for the variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With