function Chain(){
};
Chain.prototype.foo = function(){
console.log('foo called');
return this;
};
Chain.prototype.bar = function(){
console.log('bar called');
return this;
};
Chain.prototype.baz = function(){
console.log('baz called');
return this;
};
var c = new Chain();
c.baz().foo().bar();