jQuery like chaining methods.
JavaScript
function ChainingObj() {
if (!(this instanceof ChainingObj)) {
return new ChainingObj();
}
}
ChainingObj.prototype.first = function() {
console.log("foo");
return this; //important to return this.
}
ChainingObj.prototype.second = function() {
console.log("bar");
return this;
}
var a = ChainingObj().first().second();
//////////////////////////////////////////////////////