r/javascript • • Oct 09 '18

Writing Lighter, Faster JavaScript Functions

https://medium.com/p/c631739af349
40 Upvotes

23 comments sorted by

View all comments

1

u/cLnYze19N Oct 09 '18

Regardless of whether the described methods have any merit, can anyone answer why it was written this way:

const isStooge = (function() {
  const STOOGES = ['Larry', 'Curly', 'Moe'];
  return (name) => STOOGES.includes(name);
})();
isStooge('Moe');
isStooge('Joe');

And not this way:

const isStooge = (() => {
  const STOOGES = ['Larry', 'Curly', 'Moe'];
  return (name) => STOOGES.includes(name);
})();
isStooge('Moe');
isStooge('Joe');

Why the mix in function syntax?

2

u/Dynamicic Oct 10 '18

I was thinking the exact same. The inconsistency was triggering my OCD.