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");