[Javascript] Advanced Console Log Arguments

Get more mileage from your console output by going beyond mere string logging - log entire introspectable objects, log multiple items in one call, and apply C-Style string substitution to make the console work for you.

// Can accept multi args
console.log("Hello", "World", "2016"); // Hello World 2016 // Can accept any Javascript type
console.log({foo: "bar", foobar: {bar: "foo"}}); // Substitution
console.log("Hello my name is %s, %d years age, object ->", "Zhentian", 23, {name: "Zhentian"}); // Hello my name is Zhentian, 23 years age, object -> Object {name: "Zhentian"} // Styling output
console.log("Listen, this is %cimportant!", "font-size: 24px; color: red");

[Javascript] Advanced Console Log Arguments

 
上一篇:BZOJ 3594 [Scoi2014]方伯伯的玉米田(二维树状数组)


下一篇:[Javascript] Advanced Reduce: Common Mistakes