码迷,mamicode.com
首页 > 编程语言 > 详细

[Javascript] Advanced Console Log Arguments

时间:2016-05-14 06:45:36      阅读:225      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!