Skip to content

Instantly share code, notes, and snippets.

@haingdc
Created January 30, 2018 10:09
Show Gist options
  • Save haingdc/178fae30a8e9a64554383d73b2e1415b to your computer and use it in GitHub Desktop.
Save haingdc/178fae30a8e9a64554383d73b2e1415b to your computer and use it in GitHub Desktop.
iife without-iife
var person = "Alice";
var fruit = "apple";
var fruits = [
"banana",
"lemon",
"mango",
"peace"
];
for (var i = 0; i < fruits.length; i++) {
var fruit = fruits[i]; // (2)
console.log(person + " has a " + fruit);
}
console.log(person + " has an " + fruit);
// Outputs:
// Alice has a banana
// Alice has a lemon
// Alice has a mango
// Alice has a peace
// Alice has an peace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment