-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.js
60 lines (47 loc) · 1.24 KB
/
sample.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
// const promise=new Promise(function(resolve,reject){
// //async operation
// const error=true;
// if(!error){
// setTimeout(function(){
// resolve({username:'pudu',age:16});
// },1000);
// }
// else{
// reject('error:error occured')
// }
// })
// async function sample(){
// try{
// const response=await promise;
// console.log(response)
// }
// catch(e){
// console.log(e)
// }
// }
// sample();
// function set(name){
// this.name=name;
// console.log("called")
// }
// function add(email,password){
// this.email=email;
// this.password=password;
// }
// console.log(new add('pudu','[email protected]',56712));
// class set1{
// constructor(email,password){
// this.email=email;
// this.password=password;
// }
// }
// console.log(new set1('[email protected]',56712));
function outerFunction() {
const outerVariable = 'I am from outerFunction';
function innerFunction() {
console.log(outerVariable); // Access outerVariable from the lexical scope
}
return innerFunction; // Return innerFunction without invoking it
}
const closureFunc = outerFunction();
closureFunc(); // Output: I am from outerFunction