Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Doesn't work
- ```js
- var fn = (function(){
- return function(){}
- })();
- Object.defineProperty(fn, "name", {
- value: "Others",
- configurable: true
- });
- var obj1 = new fn();
- var obj2 = Object.create(fn.prototype);
- var obj3 = Object.create({constructor: fn})
- ```
- ```js
- Object.create({constructor: {name: "foo"}})
- ```
- ```js
- var fn = new Function();
- Object.defineProperty(fn, "name", {
- value: "Others",
- configurable: true
- });
- var obj1 = new fn();
- ```
- ```js
- var thing3 = (function(){
- function NamedThing2(){}
- NamedThing2.toString = function(){ return "function NamedThing333(){}" }
- console.log( NamedThing2.toString() )
- return Object.create(NamedThing2.prototype)
- })()
- ```
- ## Works, but doesn't allow me to arbitrarily set constructor name
- ```js
- var NamedThing = function(){}
- var thing = Object.create(NamedThing.prototype)
- ```
- ```js
- var obj = Object.create({constructor: function bar(){}})
- ```
Add Comment
Please, Sign In to add comment