-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebugging.js
More file actions
64 lines (54 loc) · 1.5 KB
/
debugging.js
File metadata and controls
64 lines (54 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
console.error('ff');
console.time('loop');
for (let i = 0; i < 100; i++) {
// Do stuff here
}
console.timeEnd('loop');
console.time('fetching data');
fetch('https://api.github.com/users/wesbos')
.then(data=>data.json())
.then(data=>{
console.timeEnd('fetching data');
// console.log(data);
});
const dogs = [{ name: 'rocky', age: 2 }, { name: 'rocco', age: 8 }]; // Here dogs is a array of object.
dogs.forEach(dog => {
console.groupCollapsed(`${dog.name}`);
console.log(`This is ${dog.name}`);
console.log(`${dog.name} is ${dog.age} years old`);
console.log(`${dog.name} is ${dog.age * 7} dog years old`);
console.groupEnd(`${dog.name}`);
});
function foo() {
console.log('foo')
function bar() {
console.trace();
console.log('bar');
}
bar();
}
foo()
// o/p-
// bar
// foo
function a() {
b();
}
function b() {
c();
}
function c() {
console.trace(); // Will print the stack trace
}
a();
var myCircle3 = {
radius: 1.1,
getArea: function () { return this.radius * this.radius * Math.PI; }
}
console.log(myCircle3.radius, myCircle3); // 1.1
console.log(myCircle3.getArea()); // 3.8013271108436504
console.log(myCircle3.__proto__ === Object.prototype); // true
console.log(Object.prototype.hasOwnProperty('toString')); // true
console.log(myCircle3.hasOwnProperty('radius')); // true
console.log(myCircle3.hasOwnProperty('toString')); // false (inherited, NOT own property)
console.log(myCircle3.toString()); // invoke