Javascript Array map(fun, thisArg)
Array.prototype.map = function (fun, thisArg) { if(typeof fun !== 'function') { throw new Error("The first argument must be of type function"); }/* w w w . java 2 s . c om*/ var arr = []; thisArg = (thisArg) ? thisArg : this; thisArg.forEach(function(element) { arr[arr.length] = fun.call(thisArgs, element); }); return arr; };