您的位置:首页 > Web前端 > JavaScript

[Javascript] Advanced Console Log Arguments

2016-05-14 05:32 661 查看
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");


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: