Skip to content

Instantly share code, notes, and snippets.

@coolaj86
Created March 2, 2022 08:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coolaj86/1b7f38bfe48d7ee7d7c0a1e13627f2f9 to your computer and use it in GitHub Desktop.
Save coolaj86/1b7f38bfe48d7ee7d7c0a1e13627f2f9 to your computer and use it in GitHub Desktop.

Why is this bad?

const something = (params) => value;

TL;DR Because this ISN'T bad

function (params) {
    return { value: value };
}

This looks like those 👇

(params) => { value }

All of these are the same

(params) => { value: value }
(params) => {
  value: value
}
(params) => {
  value:
    return value
}

But the first is this

(params) => {
  return value
}

But what we wanted is this

(params) => {
  return { value: value };
}

So...

Never use arrow functions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment