Created
November 7, 2020 19:44
-
-
Save itsMapleLeaf/44c2cc1312a7cdf3303be8c9a955e0eb to your computer and use it in GitHub Desktop.
arrow function explanation
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
| // this has a block, needs a return statement | |
| const fn1 = () => { | |
| return 1 | |
| } | |
| // this does the same as the above, | |
| // if you're returning something without other stuff, no need for curly braces | |
| const fn2 = () => 1 | |
| // adding parentheses is just a stylistic choice, it does the same thing | |
| const fn3 = () => ( | |
| 1 | |
| ) | |
| // if you use curly braces, that's the block form. | |
| // without `return`, you'll have a floating value that does nothing | |
| const fn4 = () => { | |
| 1 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment