首页 > 代码库 > javascript 调试 使用console.table()

javascript 调试 使用console.table()

或许你已经习惯了console.log()来调试js,非常使用,但是今天微博看到console.table()调试javascript,和console.log()类似,主要区别在于:

主要用来输出对象和数组;
更加直接的可视化,以表格形式展现;
可以单独输出某个或某几个属性;

var languages = {csharp: { name: "C#", paradigm: "object-oriented" },fsharp: { name: "F#", paradigm: "functional" }};console.table(languages);

  

Make sure the console is opened before refreshing the page, otherwise you won‘t see any output. If you did everything correct, you‘ll be rewarded with this nice, little table view: