3 ms·
why this does not work: [1,2,3].map({2:4}) (in JavaScript)? It does (or, at least, it can) if you give Array.prototype.map a suitable value. Here's one possib
by DaveInTucson 15y ago
why this does not work: [1,2,3].map({2:4}) (in JavaScript)?
It does (or, at least, it can) if you give Array.prototype.map a suitable value. Here's one possible implementation:
Array.prototype.map = function(o) {
var copy = this.slice(0); // copy semantics
for (var i in o) copy[i] = o[i];
return copy;
}