Open albseb511 opened 4 years ago
@albseb511
<!-- function parent(){ -->
let name = 'satya';
function child(){
console.log(name);
}
return child;
}
let newFunc = parent();
newFunc(); # output: satya
<!-- function makeCounter(){ -->
let count = 0;
function increment(){
count++;
console.log(count);
}
return increment;
}
let counter = makeCounter();
counter(); #output: 1
counter(); #output: 2
counter(); #output: 3
<!-- function person(name){ -->
let age = 0;
function getAge(){
return this. age;
}function setAge(newAge){
this.age = newAge;
}
function getName(){
return name;
}
return {
getName,setAge,getAge
};
}
let person1 = person("satya");
console.log(person1.getName()); #output: satya
person1.setAge(20);
console.log(person1.getAge()); #output: 20
delay
and setTimeOut()
to delay the execution.This is my first time answering GitHub issues. And I would like to take feedback.