-
table():用表格的形式显示数组或对象
数组:const a=[1,2,444,66]; console.table(a)
对象:const a=[{a:'this a',b:'this b'},{a:'this a1',b:'this b1'}]; console.table(a)
只打印部分对象:const a=[{a:'this a',b:'this b',c:'this c'},{a:'this a1',b:'this b1',c:'this c1'}]; console.table(a,['a','c'])
- time(timename)&timeEnd(timename):两者连用,开启一个计时器计算某操作执行时长。
console.time("timer1"); setTimeout(() => { console.timeEnd("timer1"); }, 1000);
上面那个setTimeout计时器执行时长为:1003.312255859375 ms - count():记录打印同一内容的次数
console.count('Hello'); console.count('Hello word'); console.count('Hello'); console.count('Hello'); console.count('Hello word'); console.count('Hello');
上面hello 打印了4次,hellow word 打印了2次 - assert():当不满足条件才打印
const age = 18,height=30; console.assert(age > 17, "User is unable to drive");//true console.assert(age > 21, "User is below 21");//false console.assert(height>17,'height <17');//true console.assert(height>21,'height<21');//true
const age = 18,height=15; console.assert(age > 17, "User is unable to drive");//true console.assert(age > 21, "User is below 21");//false console.assert(height>17,'height <17');//false console.assert(height>21,'height<21');//false
09-02
1448
01-25
554