.: -)
( ) . map:
a.map(function(x){x.frob()})
. :
a.mapm(A.frob)
A - A, mapm - Array, this ( A ). mapm :
Array.prototype.mapm = function (method)
{
return this.map(function (x) { return method.apply(x) } )
};
:
["a", "b", "c"].mapm("".toUpperCase) ==> ["A", "B", "C"]
The only problem is that you added a new element mapmto each array, although it is ignored by most methods Array, for example. lengthand map.
source
share