-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path22_Nested_Scope.js
More file actions
54 lines (33 loc) · 1.01 KB
/
22_Nested_Scope.js
File metadata and controls
54 lines (33 loc) · 1.01 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
// 1}
function one(){
const username = "tarun"
function two(){
const website = "youtube"
console.log(username)
}
two() // function two is called but its parent is not called so give no result.
}
// 2}
function three(){
const username = "tarun"
function four(){
const website = "youtube"
console.log(username) // gives result as username is defined in the heigher scope.
}
//console.log(website) // will give error because website is defined inside the four and its scope is only till the four.
four()
}
three() // parent is also called so gives result
// CONCLUSION ::::
// Child function parent function ki values ko excessed kr sakta hai
// But parent function child function ki values ko excessed nhi kr sakta
// 3} similarly
if (true){
const name = "Mr. Tarun"
if(true){
const name2 = "Lakshita"
console.log(name)
}
// console.log(name2) // will not run
}
// console.log(name) // will not run