-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclosures.js
More file actions
27 lines (23 loc) · 740 Bytes
/
closures.js
File metadata and controls
27 lines (23 loc) · 740 Bytes
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
function closureScoped(job) {
if (job=="designer") {
return (name)=>console.log(`my name is ${name} my job is ${job}`)
}
else if (job=="teacher") {
return (name)=>console.log(`my name is ${name} my job is ${job}`)
}
else {
return (name)=>console.log(`my name is ${name} my job is ${job}`)
}
}
closureScoped("designer")("hans");
function curryingClosure(job){
return function(name) {
if (job=="Teacher")
console.log(` ${name} can you explain closures? ${job}`)
else if (job=="javaScripter")
console.log(`${name} can explain closure and currying because he is a ${job}`)
else
console.log(`${name} what is your malfunction?`)
}
}
curryingClosure("javaScripter")("hans")