Skip to content

Instantly share code, notes, and snippets.

@user512
Last active August 29, 2015 14:27
Show Gist options
  • Save user512/76c2161aafaf1a1f6ad9 to your computer and use it in GitHub Desktop.
Save user512/76c2161aafaf1a1f6ad9 to your computer and use it in GitHub Desktop.

Javascript Lecture

Closure

function(thisOtherNumber){
  return numberToAdd + theOtherNumber;  
}

That function remembers variables numberToAdd that were around when the function was declared.

IIFE

Immediately-invoked function expression
  • Avoid variable hoisting from within blocks
  • Protect against polluting the global environment
  • Simultaneously allow public access to methods....

Modules

Emulate the concept of classes so we can include public and private methods & variables inside a single object
  • thus shielding particular parts from the global scope.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment