JS Chaining
by mrrodd
JavaScript
var Calc = function(start) {
this.Add = function(x) (
return this;
};
this.Multiply = function(x) {
return this;
};
this.Equals = function(callback) {
return this;
};
}
new Calc(0)
.Add(1)
.Add(2)
.Multiply(3)
.Equals(function(result) {
document.write(result);
});