Skip to content

Instantly share code, notes, and snippets.

@sakex
Created April 7, 2020 20:26
Show Gist options
  • Save sakex/137ea5b5027f10af89e7fe55393d1d80 to your computer and use it in GitHub Desktop.
Save sakex/137ea5b5027f10af89e7fe55393d1d80 to your computer and use it in GitHub Desktop.
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