Debugging JavaScript in Chrome - toString doesn't give me what I need

As the answers in this question suggest , you can override the method toString()

on objects to provide useful information while debugging (at least). This works well in Firebug, but it doesn't help at all in Chrome:

x = { toString: function () { return 'test' } }

      

gives a very useful conclusion:

Object

      

so far in Firebug this is much better:

test { toString=function()}

      

I know Chrome allows me to check the properties of an object. This is useful, but it's much easier to have a list of object names, at least a few of the most important ones, so you don't have to dig out 50 properties of a complex object to find out one value.

So, is it possible to make the debug output in Chrome more useful?

EDIT

This is what I want to achieve:

v  [result of ???() on x]
    a: 1
    b: 'foo'
  v c: [result of ???() on x.c]
      foo: 'bla bla bla'
    > bar: [result of ???() on x.c.bar]

      

+3


source to share


1 answer


You can use it like this:

console.log(x.toString(), x)

      



It will give you the result x.toString()

and the expandable view x

on the same line.

-1


source







All Articles