`

JavaScript之ECMAScript6新特性之_01_开篇

阅读更多
点此查看全部:
http://es6-features.org



Constants
Constants
Support for constants (also known as "immutable variables"), i.e., variables which cannot be re-assigned new content. Notice: this only makes the variable itself immutable, not its assigned content (for instance, in case the content is an object, this means the object itself can still be altered).


const PI = 3.141593
PI > 3.0



//  only in ES5 through the help of object properties
//  and only in global context and not in a block scope
Object.defineProperty(typeof global === "object" ? global : window, "PI", {
    value:        3.141593,
    enumerable:   true,
    writable:     false,
    configurable: false
})
PI > 3.0;






分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics