为什么在使用' var'声明变量时,javascript中可配置的属性描述符的默认值为false

时间:2017-10-10 05:57:25

标签: javascript

为什么属性'可配置'默认为' false'当使用' var'声明变量时如果变量在全局范围内声明而没有' var'它是可配置的' true'?

   // variable declared in global scope with 'var' keyword

          var foo = 2;
          Object.getOwnPropertyDescriptor(this, 'foo')

   // will print {value: 2, writable: true, enumerable: true, configurable: false}


   // But with variable declared without var has configurable true

          bar = 2;   

   // will print {value: 2, writable: true, enumerable: true, configurable: true}

0 个答案:

没有答案
相关问题