Self-Executing Anonymous Functions Self-Executing Anonymous Functions / tutorial / free

When learning JavaScript, with all the attention given to variables, functions, ‘if’ statements, loops and event handlers, often little is done to educate you on how you might cleanly organise your code into a cohesive, structurally-sound whole.
3 favorites
submitted over 4 years ago, by pineapple
Self-Executing Anonymous Functions popular tutorial



This is best explanation of an IIFE that i've seen!

I have a similar wrapper and think of it as a 'private block'. While aliasing to exports is common in some modules, I usually just alias global to window to make it a little easier to read.

(function(global){ // private scope
  var foo,bar;
  foo = 'Private Var'; = 'Hello World';

>>> foo
>>> ReferenceError: foo is not defined

>>> bar
>>> Hello World

SkinnyGeek1010, over 4 years ago


I actually thought the same thing -- that's a great article

blueberry, over 4 years ago

Login or to comment.

Tutorials are any resources you learn from.

Examples: an intro to html5 screencast, a pdf about git, photoshop effects tutorials, meta-programming in ruby, lambda calculus, higher-order fixed-point combinators.

Tools are websites, apps or services used -on- your project (indirectly), to aid the process.

Examples: A color scheme generator, email marketing software, usability heat maps, css3 code generators, a downloadable png compressor.

Assets are downloadable files used -in- your projects, usually as code, textures, or images.

Examples: a jquery sticky menu, photoshop brushes, background textures, mvc frameworks, twitter bootstrap, 960 grid system.