Skip to content

Instantly share code, notes, and snippets.

@mbroadst
Created February 25, 2016 15:33
Show Gist options
  • Save mbroadst/4276db2d3331dac78a68 to your computer and use it in GitHub Desktop.
Save mbroadst/4276db2d3331dac78a68 to your computer and use it in GitHub Desktop.
'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