Created
January 30, 2018 10:09
-
-
Save haingdc/178fae30a8e9a64554383d73b2e1415b to your computer and use it in GitHub Desktop.
iife without-iife
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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