what does line mean: var DYN

This question already has an answer here:

  • What does “var FOO = FOO || {}” (assign a variable or an empty object to that variable) mean in Javascript? 7 answers
  • What does “variable = variable || {}” mean in JavaScript [duplicate] 4 answers

  • 如果DYN_WEB不为空,它将采用已经为DYN_WEB设置的值,否则为其分配一个空对象。


    This is shorthand for

    if ( ! DYN_WEB ) {
      DYN_WEB = {}
    }
    

    or

    var DYN_WEB = DYN_WEB ? DYN_WEB : {}
    

    it means if the variable DYN_WEB has a value which is evaluated to binary true, then keep that value, otherewise assign {} to it. The latter will happen if the previous value of the variable is 'falsy' ie. one of the false, null, undefined, NaN, 0, "", [] or {} and in case it's not defined.

    链接地址: http://www.djcxy.com/p/95286.html

    上一篇: “意味着在JavaScript数组创建?

    下一篇: 线的含义是什么:var DYN