Created
November 3, 2016 02:22
-
-
Save felipeblini/0e2665456c636f374d73e8b80b12a9e2 to your computer and use it in GitHub Desktop.
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 MyClass = function() {}; | |
var properties = { | |
p: { | |
value: 42, | |
writable: false, | |
enumerable: true, | |
configurable: false | |
} | |
}; | |
// cria um objeto herdando o protótipo de MyClass e com propriedas definidas | |
var obj = Object.create(MyClass.prototype, properties); | |
console.log(obj.p); // 42 | |
// alterando o valor da propriedade p | |
obj.p = 1000; | |
// p continua 42 pois o writable dele está como false | |
console.log(obj.p); // 42 | |
// deletando a propriedade p | |
delete obj.p; | |
// p continua existindo pois configurable foi definida como false | |
console.log(obj.p); // 42 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment