Last active
October 10, 2017 07:35
-
-
Save Yang03/01f28ec95593df3cadc17aedb1b808f6 to your computer and use it in GitHub Desktop.
Object.defineProperty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = {} | |
Object.defineProperty(foo, 'name', { | |
configurable: true, //是否可以delete foo.delete | |
enumerable: true, // 是否for in可以返回属性 | |
writable:true, //是否可以重新赋值 | |
value: 'kobe' | |
}) | |
var descriptor = Object.getOwnPropertyDescriptor(foo, 'name') | |
console.log(descriptor.value) | |
console.log(foo.name) // kobe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sum([42, 3, -1])