Objet statique
const counter = {
count: 0, next: function () { return ++this.count; }, };🥷Il est important de comprendre que this=counter dans la fonction next() par ce que on excute counter.next();
🤢Arrow fonction
Pipeline !
const counter = {
count: 0,
next: function () {
++this.count;
return this;
},
};
🪳Attention:
const counter = {
count: 0,
next: function () {
return ++this.count;
},
};
let fxNext = counter.next;
console.log(fxNext());
const counter = {
count: 0,
next: () => ++this.count
};
console.log(counter.count);