Created
August 9, 2020 03:41
-
-
Save anil-pace/e1d1ba4377f273b2d8d1348d900ff46a to your computer and use it in GitHub Desktop.
Chaining in JS
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 = { | |
| result: 0, | |
| addNumber: function (a, b) { | |
| this.result = a + b; | |
| return this; | |
| }, | |
| multiplyNumber: function (a) { | |
| this.result = this.result * a; | |
| return this; | |
| }, | |
| divideNumber: function (a) { | |
| this.result = this.result / a; | |
| return this; | |
| } | |
| } | |
| obj.addNumber(10, 20).multiplyNumber(3).divideNumber(5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment