Skip to content

Instantly share code, notes, and snippets.

@cuipengfei
Created December 15, 2013 06:07
Show Gist options
  • Save cuipengfei/7969526 to your computer and use it in GitHub Desktop.
Save cuipengfei/7969526 to your computer and use it in GitHub Desktop.
Implement Map with Reduce
module.exports = function arrayMap(arr, fn) {
return arr.reduce(function (acc, current) {
acc.push(fn(current))
return acc
}, [])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment