[removed] is this a conditional assignment?

后端 未结 4 755
猫巷女王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:08

    It's the same as saying:

    if( !(_gaq) ) {var _gaq = [];}
    

    (This can be done since the var is hoisted above the conditional check, thereby avoiding a 'not defined' error, and it will also cause _gaq to be automatically treated as local in scope.)

提交回复
热议问题