Last active
October 31, 2015 10:14
-
-
Save khanghoang/9980a7455013534871e4 to your computer and use it in GitHub Desktop.
Map implementation
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
function map(array, cb, context) { | |
return function(array, cb) { | |
var returnArray = []; | |
for (var i = 0; i < array.length; i++) { | |
returnArray.push(cb(array[i], i, array)); | |
} | |
return returnArray; | |
}.call(null, array, cb.bind(context)); | |
} | |
module.exports = map; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment