首页 > 编程语言 > 详细

[Javascript] Advanced Console Log Arguments

时间:2016-05-14 06:44:12      阅读:238      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/Answer1215/p/5491822.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!