Validating a custom object in the Chrome Developer Console

Interestingly, the Chrome development tools support something like the Ruby inspect or Objective C description methods for printing a meaningful line instead of just showing the name of the object constructor when examining objects in the console.

clearifying screenshot Thus, in this case - instead of showing "Crossing, Crossing, Crossing, ...", some user string will be displayed for each object (generated by the method of this object).

ps. I know that there is a console.table method that can produce some good output, but it would be nice to have more universal formatting of objects.

+6
source share
1 answer

The name of the function you are looking for is custom formats

Basically, you should enable this function in Chrome and do this while running your script, you write your formatters in the magical global var window.devtoolsFormatters

Official document:

https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview

+2
source

All Articles