Hacker News new | ask | show | jobs
by tienthanh8490 4072 days ago
You just need to "return this;" for the methods whose result need to be chained.

Example:

var a = function(x){ this.x = x+1; return this; }

var b = function(){ this.x *= 2; return this.x; }

a(3).b(); //result = 8