3

I am using Dean Edwards' Base.js library to provide OOP in javascript. The objects it creates look like "klass.proto.constructor" in Chrome's console. Is it possible to override its display name to show human-readable labels like "MyClass" etc.

I think it could be achieved by playing with toString property, but i have no idea how to do this.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
jsmarkus
  • 1,482
  • 1
  • 16
  • 21

2 Answers2

3

In the Chrome console, the object's toString isn't called. Instead there is an interactive representation of the object's structure.

See my answer to a similar question:

https://stackoverflow.com/a/31351527/2482570

Community
  • 1
  • 1
Max Heiber
  • 14,346
  • 12
  • 59
  • 97
0

If I'm not mistaken, you would set

Your_object.prototype.toString = function() {
    return "MyClass"; /* or whatever */
}

If you need to do this on a regular basis for all the objects returned from Base.js, you have to patch the library :(

Alexander Pavlov
  • 31,598
  • 5
  • 67
  • 93