Skip to content

Instantly share code, notes, and snippets.

@getify
Created May 16, 2014 16:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save getify/22ac00ba029e707f19f5 to your computer and use it in GitHub Desktop.
Save getify/22ac00ba029e707f19f5 to your computer and use it in GitHub Desktop.
function foo(){}
foo.prototype = 2;
Object.defineProperty(foo,"prototype",{writable:false});
Object.getOwnPropertyDescriptor(foo,"prototype"); // Object {value: 2, writable: false, enumerable: false, configurable: false}
foo.prototype; // 2
function bar(){}
Object.defineProperty(bar,"prototype",{value:2,writable:false});
Object.getOwnPropertyDescriptor(bar,"prototype"); // Object {value: 2, writable: false, enumerable: false, configurable: false}
bar.prototype; // bar {}
// what!?!?! ^^^^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment