Wednesday, 21 August 2013

How to implicitly log a JavaScript object as a string?

How to implicitly log a JavaScript object as a string?

Consider:
var o = { a: 1, b: 2, toString: function() { return "foo"; } };
In Chrome dev tools:

Is there anything I could do to the object such that o is displayed in the
debug console as "foo" instead of the full object?

No comments:

Post a Comment