I’ll keep this brief.

I’ve been noticing a lot of public code snippets out there which declare consts using the arrow function syntax;

const addOne = (number) => {
  return number + 1;
}

As opposed to the classic pre-ES2015 form,

function addOne(number) {
  return number + 1;
}

My use of the term “classic” reveals my bias, as opposed to calling it “ancient” or “crappy old”.

There are two things I prefer about the classic form;

  1. You know instantly that it’s a Function by just looking at the line
  2. Why capture a scope context that you never use?

Now, to be clear, I’m totally down with something along these lines;

Transformer.prototype.transform = function transform(nouns) {
  const renamer = (noun) => {
    const { renameMap } = this;
    return (renameMap.has(noun) ? renameMap.get(noun) : noun);
  };
  const inclusions = (noun) => this.includeSet.has(noun);

  if (this.shouldRename) {
    // filter both inbound & outbound
    return nouns.filter(inclusions).map(renamer).filter(inclusions);
  }
  return nouns.filter(inclusions);
};

It’s a convoluted example, and could be approached very differently … but as written it makes a lot of sense to declare a few Function consts that inherit the scope context.

I’m all in favor of adopting a modern JavaScript syntax, as long as it serves a purpose in the code. You saw me up there deconstructing an Object with reckless abandon, right? I find that syntax much cleaner and more expressive than a this assignment, and I’ll choose it in a heartbeat.

But I propose that an old-school function declaration is the cleaner, more expressive style when either one could meet your needs.