This commit is contained in:
Hanzhang ma 2024-06-23 23:57:39 +02:00
parent fcc6ef2a49
commit d758882972

44
6.4NFE/t.js Normal file
View 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");