Skip to content

Latest commit

 

History

History
54 lines (52 loc) · 1.08 KB

10_debug.md

File metadata and controls

54 lines (52 loc) · 1.08 KB

1. console.log

Must commonly used. Print the results to debug.

let someObject = { str: "Some text", id: 5 };
console.log(someObject); 
// output: {str: "Some text", id: 5}

console.log(3 + 5);
// output: 8

2. console.time

Calculate the duration of a specific operation.

console.time("answer time");
alert("Click to continue");
// some function
console.timeEnd("answer time");

3. console.table

Displays tabular data as a table.

const Willy = { name: 'Willy', age: 20, handsome: false };
const Parker = { name: 'Parker', age: 23, handsome: true };
const Sam = { name: 'Sam', age: 25, handsome: false};

console.table([Willy, Parker, Sam]);
(index) name age handsome
0 Willy 20 false
1 Parker 23 true
2 Sam 25 false