Skip to content

Instantly share code, notes, and snippets.

@itsMapleLeaf
Created November 7, 2020 19:44
Show Gist options
  • Select an option

  • Save itsMapleLeaf/44c2cc1312a7cdf3303be8c9a955e0eb to your computer and use it in GitHub Desktop.

Select an option

Save itsMapleLeaf/44c2cc1312a7cdf3303be8c9a955e0eb to your computer and use it in GitHub Desktop.
arrow function explanation
// 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