-
Notifications
You must be signed in to change notification settings - Fork 0
/
scope.js
55 lines (43 loc) · 990 Bytes
/
scope.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
var c = 30
let a = 100
if (true) {
let a = 10
const b = 20
// console.log('INNER ', a)
}
// console.log(a)
// console.log(b)
// console.log(c)
// for (let i = 0; i < Array.length; i++) {
// const element = array[i];
// }
// Nested scope
function one() {
const username = "Hello Ravi"
function two() {
const website = "HelloRavi"
console.log(username)
}
// console.log(website)
// two()
}
// one()
// if (true) {
// const username = "Hello Ravi"
// if (username === "Hello Ravi") {
// const website = "HelloRavi"
// console.log(username + website)
// }
// // console.log(website)
// }
// console.log(username)
// +++++++++++++++++++++++ Intresting ++++++++++++++++++++++++++++
console.log(addOne(5))
function addOne(num) {
return num + 1
}
// console.log(addtwo(10)) // can't access this function before declation
const addtwo = function (num) {
return num + 2
}
console.log(addtwo(10))