Created
October 11, 2014 11:12
-
-
Save zhang6464/377f34c479e01b65a2eb to your computer and use it in GitHub Desktop.
javascript Array.prototype.map implement.
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(){ | |
if( typeof Array.prototype.map == 'function') | |
return; | |
Array.prototype.map = function(callback){ | |
var i = 0, | |
length = this.length, | |
res = []; | |
if( callback && typeof callback == 'function' ){ | |
for(;i<length;i++) | |
res[i] = callback(this[i]); | |
} | |
return res; | |
} | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment