-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path32.js
62 lines (44 loc) · 1020 Bytes
/
32.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
// lexical scoping
function access(){
let userName ='jhala'
function childAccess(){
let anotherUser = 'PadiAlu'
console.log(userName)
}
function macho(){
let age = 21;
let Religion = 'Hindu'
function acquire(){
console.log(anotherUser)
}
}
childAccess()
macho()
}
access()
// closure
// isme pura ka pura lexical scope return hota he
//A closure is a function that retains access to its lexical scope even when the function is executed outside that scope.
function makeFun(){
const name = 'mozilla'
function displayName(){
console.log(name);
}
return displayName;
}
const myFunc = makeFun();
myFunc();
function add(){
let count = 0;
return function myFunc(){
count++;
return count
};
}
let answer = new add()
console.log(answer())
let fun = function nitesh(){
return ('Hello')
}
console.log(fun())
// welldone javascript series finished