Skip to content

Instantly share code, notes, and snippets.

@Go7hic
Created January 11, 2015 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Go7hic/52d7684a63599c6a6ec0 to your computer and use it in GitHub Desktop.
Save Go7hic/52d7684a63599c6a6ec0 to your computer and use it in GitHub Desktop.
链式调用
var obj = {
value = 1,
increment: function() {
this.value += 1;
return this;
},
add: function (v) {
this.value += v;
return this
},
shout: function() {
alert(this.value)
}
}
// 链式调用方法
obj.increment().add(3).shout();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment