Skip to content

Instantly share code, notes, and snippets.

@teramako
Created March 19, 2013 05:06
Show Gist options
  • Save teramako/5193838 to your computer and use it in GitHub Desktop.
Save teramako/5193838 to your computer and use it in GitHub Desktop.
Object.setPrototypeOf の作成。Object.prototype.__proto__ が getter/setter として定義されていないと不可。
/**
* @see https://mail.mozilla.org/pipermail/es-discuss/2013-March/029259.html
*
* @name Object.setPrototypeOf
* @function
* @param {Object} aTarget
* @param {Object} aPrototype
*/
(function() {
var protoDesc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__");
if (typeof protoDesc.set === "function") {
Object.defineProperty(Object, "setPrototypeOf", {
value: Function.prototype.call.bind(protoDesc.set),
configurable :true,
writable: true
});
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment