javascript-learner/4.4this/t2.js

17 lines
295 B
JavaScript
Raw Permalink Normal View History

2024-06-02 15:32:46 +02:00
let ladder = {
step: 0,
up() {
this.step++;
return this;
},
down() {
this.step--;
return this;
},
showStep: function() { // shows the current step
alert( this.step );
return this;
}
};
ladder.up().up().down().showStep().down().showStep(); // shows 1 then 0