1

When an object is created via the new function(){} method, the object inherits the constructors name:

new function(){this.x=616};         // Object {x: 616}
new function Func(){this.x=616};    // Func {x: 616}

What I want to know is how to change the objects visible-name once constructed... I've tried re-naming the object via the constructor:

[object].__proto__.constructor.name=[new name]; // Func {x: 616}

I've even tried re-defining the constructor itself:

Object.defineProperty([object].__proto__,'constructor',{
    value:function [new name](){},
    configurable:true
});

// Func {x: 616}

But the objects visible-name remains the same, and that is the extent of my knowledge on this topic! All help greatly appreciated as always guys. Thx...

Lex
  • 11
  • 3
  • I don't think you can change it. But I also think that you should not care about the displayed name - it's a debugging aid and nothing else. – Bergi May 02 '18 at 18:29
  • Don't use `__proto__`. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto – idream1nC0de May 02 '18 at 18:47
  • forgive me guys this IS for purely aesthetic reasons, a nesting of objects is worse than a nesting of divs, this helps identify one `Object{}` from another. ps: agree about not using `__proto__`, but I'm also working in IE and on Gadgets, so the code is X-browser/version and only a basic example so you lot understand what I mean. – Lex May 02 '18 at 19:16

0 Answers0