这个Javascript行有什么作用? [英] What does this Javascript line do?

查看:104
本文介绍了这个Javascript行有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

什么是var _gaq = _gaq || []; ”的for?





var _gaq = _gaq || [];

我不确定这行是干什么的?有人可以向我解释这个吗?

I'm not sure what this line is doing? Can someone explain this to me?

推荐答案

这与

This is similar to doing

var _gaq = _gaq ? : _gaq : [];

这意味着如果设置 _gaq 它将设置为 _gaq ,否则它将默认为一个新的空数组。

It means that if _gaq is set, it'll set it to _gaq, otherwise it will default to a new empty array.


  • var 表示它是本地范围

  • _gaq 是变量

  • || 表示或

  • var means it's local scope
  • _gaq is the name of the variable
  • || means or

这就是说,如果 _gaq 尚不存在,请将其设置为 [] 的意思。

It's saying that if _gaq doesn't already exist, set it to a new array which is what [] means.

这篇关于这个Javascript行有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆