chrome调试工具

Console.table

 

var languages = [
    { name: "JavaScript", fileExtension: ".js" },
    { name: "TypeScript", fileExtension: ".ts" },
    { name: "CoffeeScript", fileExtension: ".coffee" }
];

console.log(languages);
结果
[Object, Object, Object]
  1. 0: Object
  2. 1: Object
  3. 2: Object
  4. length: 3
  5. __proto__: Array[0]
[Object, Object, Object]
  1. 0: Object
  2. 1: Object
  3. 2: Object
  4. length: 3
  5. __proto__: Array[0]
var languages = [
    { name: "JavaScript", fileExtension: ".js" },
    { name: "TypeScript", fileExtension: ".ts" },
    { name: "CoffeeScript", fileExtension: ".coffee" }
];

console.table(languages);

结果如下

(index)
name
fileExtension
1
"TypeScript"
".ts"
0
"JavaScript"
".js"
2
"CoffeeScript"
".coffee"
     

而且name等列是可排序状态。

但是Console.table适用于tagle结构化的数据,如果是非格式的数据,多数单元格会出现undifined的值

Console.time()

支持Chrome 2, Firefox 10, Safari 4, and Internet Explorer 11.

var i, output = "";

// Remember when we started
var start = new Date().getTime();

for (i = 1; i <= 1e6; i++)//1e6=1000000
  output += i;

// Remember when we finished
var end = new Date().getTime();

// Now calculate and output the difference    
console.log(end - start);

可以替换成


 

var i, output = "";

// Start timing now
console.time("concatenation");

for (i = 1; i <= 1e6; i++)
    output += i;

// ... and stop.
console.timeEnd("concatenation");


 

 

 

 

 

 

 

 

你可能感兴趣的:(每日一学)