Created
April 7, 2020 20:26
-
-
Save sakex/137ea5b5027f10af89e7fe55393d1d80 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 forEach(arr, func) { | |
const len = arr.length; | |
for(let i = 0; i < len; ++i) func(arr[i]) | |
} | |
const l = [1,2,3,4,5]; | |
function logTimes2(x) { | |
console.log(x*2); | |
} | |
forEach(l, logTimes2); | |
forEach(l, function(x){logTimes2(x)}); | |
forEach(l, x => console.log(x*2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment