-
Notifications
You must be signed in to change notification settings - Fork 0
/
inter1.js
68 lines (57 loc) · 1.01 KB
/
inter1.js
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
65
66
67
68
// # 1
function first() {
return {
hello: "world!",
};
}
function second() {
return; // JavsScript will automatically insert a semicolon here
{
hello: "world!";
}
}
console.log(first()); // { hello: 'world!' }
console.log(second()); // undefined
// # 2
console.log("2 example: ");
var a = 5;
var writeA = function () {
console.log(a);
// var a = 10;
};
console.log(writeA()); // undefined
// my answer : 10
// # 3
// for (let i = 0; i < 6; i++) {
// setTimeout(function () {
// console.log(i);
// }, i * 600);
// }
// # 4
const something = {
object: "Javascipt",
hello() {
return `Hello, ${this.object}!`;
},
// Arrow function does not have its own this
// this: typeof globalThis or window
goodbye: () => {
return `Hello, ${this.object}!`;
},
};
console.log(something.hello());
console.log(something.goodbye());
// # 5
var a = 1;
function first() {
// a++;
var a = 6;
function second() {
a++;
var a = 3;
console.log(a);
}
second();
}
first();
// 3