add NFE
This commit is contained in:
parent
fcc6ef2a49
commit
d758882972
44
6.4NFE/t.js
Normal file
44
6.4NFE/t.js
Normal file
@ -0,0 +1,44 @@
|
||||
function sayHi(){
|
||||
console.log("Hi");
|
||||
|
||||
sayHi.counter++;
|
||||
}
|
||||
|
||||
console.log(sayHi.name)
|
||||
|
||||
let user = {
|
||||
sayHi(){
|
||||
|
||||
},
|
||||
|
||||
sayBye: function (){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
console.log(user.sayBye.name)
|
||||
console.log(user.sayHi.name)
|
||||
|
||||
function ask(question, ...handlers){
|
||||
let isYes = confirm(question);
|
||||
|
||||
for(let handler of handlers){
|
||||
if (handler.length == 0){
|
||||
if (isYes) handler();
|
||||
}else{
|
||||
handler(isYes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ask("Question?", () => console.log('You said yes'), result => console.log(result))
|
||||
|
||||
console.log("the difference between the counter.count and closure is the counter.count can be accessed outside but closure cannot");
|
||||
|
||||
let sayHi = function func(who){
|
||||
console.log(`Hello, ${who}`);
|
||||
};
|
||||
|
||||
sayHi("John");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user