koalabears / koala-roar

Our 4th project - a twitter clone. ROAR!
http://quiet-chamber-5330.herokuapp.com/
4 stars 0 forks source link

IIFEs + exporting node modules = overkill! #44

Closed minaorangina closed 8 years ago

minaorangina commented 8 years ago

Let's take handler.js for example.

You are wrapping everything in an IIFE (immediately-invoked function expression) and exporting that IIFE into your index.js.

IIFEs are great for privacy in the frontend, but not necessary here. When exporting/requiring modules, anything that's left behind is automatically private.

Think of it as locking your code in a vault, then putting your vault in another vault, then dropping that vault in the sea with a ball-and-chain attached, before adding another vault. Overkill. :wink:

jackcarlisle commented 8 years ago

Ok thanks Mina, that helps with the understanding of why we need IIFEs! Really useful