learn this, but not very clear
This commit is contained in:
16
4.4this/t2.js
Normal file
16
4.4this/t2.js
Normal file
@@ -0,0 +1,16 @@
|
||||
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
|
||||
Reference in New Issue
Block a user