Arrow fonksiyonları bir nesnede Method olarak kullanalım.
Kod:
window.name = "global";
var person = {
name: "Ahmet",
shout: function () {
console.log("Benim adım...: ", this.name);
},
shout2: () => {
console.log("Benim adım...: ", this.name);
},
// Shorter syntax
shout3() {
console.log("Benim adım...: ", this.name);
}
};
person.shout(); // "Ahmet"
person.shout2(); // "global"
person.shout3(); // "Ahmet"