Created
January 30, 2018 10:11
-
-
Save haingdc/ec6ca7a1c0c4429e9dc759cbc2720d3f to your computer and use it in GitHub Desktop.
iife presence
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++) { | |
(function() { | |
var fruit = fruits[i]; | |
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 apple <- cái ta cần |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment