Chaining Functions using "This"
var MathObject = function (initialValue) {
this.value = initialValue || 0;
this.add = function (num) {
this.value += num;
return this;
};
this.sub = function (num) {
this.value -= num;
return this;
};
};
var myMath = new MathObject(10);
console.log(myMath.value);
myMath.add(5);
console.log(myMath.value);
myMath.add(5).add(6).sub(20);
console.log(myMath.value);INFO