Home > Net >  How to make the console of Firefox output a dom node differently by using %o and %O , just like how
How to make the console of Firefox output a dom node differently by using %o and %O , just like how

Time:09-18

The following is an example (using Chrome)

// Output an expandable DOM node
console.log('%o',document.body.firstElementChild);
// Output a dom object, which is equivalent to console.dir(document.body.firstElementChild)
console.log('%O',document.body.firstElementChild); 

CodePudding user response:

There's also %O which is supported in major browsers. According to the spec it's pretty similar to %o.

%O An object with generic JavaScript object formatting is a potentially expandable representation of a generic JavaScript object.

%o An object with optimally useful formatting is an implementation-specific, potentially-interactive representation of an object judged to be maximally useful and informative.

more detail...

  • Related