Last active
August 29, 2015 14:27
-
-
Save chuck0523/2a8deaa83c5db0211606 to your computer and use it in GitHub Desktop.
This file contains 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
(function() { | |
_.each([2, 5, 8], function(num) { | |
//console.log(num); // 2 , 5, 8 | |
}); | |
var x = _.map([2, 5, 8], function(num) { | |
return num * 2; | |
}) | |
//console.log(x); // [4, 10, 16] | |
var log = function(x){console.log(x)} | |
// each by pure JS | |
var ary = [2, 5, 8]; | |
for(var i = 0; i < ary.length; i++) { | |
console.log(ary[i]); | |
} | |
//map by pure JS | |
var ary = [2, 5, 8]; | |
for(var i = 0; i < ary.length; i++) { | |
ary[i] *= 2; | |
} | |
console.log(ary); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment