Created
January 7, 2020 20:39
-
-
Save valmassoi/a8bdb71b099fb36f69e69f50dec47786 to your computer and use it in GitHub Desktop.
chain functions like jQuery
This file contains 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
const chain = { | |
first: () => { | |
console.log(1); | |
return chain; | |
}, | |
third: function() { // cant use fat arrow, binds this | |
console.log(3); | |
return this; | |
}, | |
second: () => { | |
console.log(2); | |
return chain; | |
}, | |
} | |
chain.first().second().third(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment