Skip to content

Instantly share code, notes, and snippets.

@shri3k
Created August 10, 2014 22:48
Show Gist options
  • Save shri3k/f12bb33a19e383c3ec53 to your computer and use it in GitHub Desktop.
Save shri3k/f12bb33a19e383c3ec53 to your computer and use it in GitHub Desktop.
Creating chains in js
function Test(){
this.x = "I'm x";
this.publicFn = function(){
console.log("I'm a instance method");
}
}
Test.prototype = {
protoFn : function(){
console.log("And I'm a proto function");
return this;
}
}
var z = new Test();
z.protoFn().publicFn();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment