Created
January 11, 2015 13:48
-
-
Save Go7hic/52d7684a63599c6a6ec0 to your computer and use it in GitHub Desktop.
链式调用
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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