[removed] is this a conditional assignment?

后端 未结 4 698
猫巷女王i
猫巷女王i 2021-02-05 12:45

From the google analytics tracking code:

var _gaq = _gaq || [];

how does this work?

Is it a conditional variable value assignment? Is i

4条回答
  •  梦如初夏
    2021-02-05 13:11

    Yes, it is.

    The || operator evaluates to its leftmost "truthy" operand.
    If _gaq is "falsy" (such as null, undefined, or 0), it will evaluate to the right side ([]).

提交回复
热议问题