Created
February 25, 2016 15:33
-
-
Save mbroadst/4276db2d3331dac78a68 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
'use strict'; | |
function createType() { | |
function Thing() {}; | |
Thing.prototype = Object.create(Object.prototype, { | |
first: { value: 1, enumerable: true, writable: true, configurable: false }, | |
second: { value: 2, enumerable: true, writable: true, configurable: false } | |
}); | |
return Thing; | |
}; | |
var Test = createType(); | |
// var t1 = Object.seal(new Test()); | |
var t1 = new Test(); | |
t1.first = 2; | |
t1.second = 3; | |
t1 = Object.seal(t1); | |
t1.third = 4; // expected error: TypeError: Can't add property third, object is not extensible | |
var t2 = Object.seal(new Test()); | |
t2.first = 2; // unexpected TypeError, `first` is a defined property and should still be writable? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment