3 ms·
His point was: x = [1]; x["test"] = 555; x.map(function (y) { return y; }); // [1] That's [1], not [1, 555]. You can access the array from the map int
by nothrabannosir 12y ago
His point was:
x = [1]; x["test"] = 555; x.map(function (y) { return y; });
// [1]
That's [1], not [1, 555]. You can access the array from the map interface, but not the other way around.
- dsp1234 12y agoThe array prototype functions are only specified by the standard to deal solely with numeric keys, but the lines between and object and array are still pretty blurry. The use case for each is different, but the original question far above was "array/map combo. Have you ever seen anything like that in another language?", and clearly JavaScript is very similar even if not exact. var x = {}; x[0] = 1; x.length = 1; x.map = Array.prototype.map; x.map(function(y) {return y;}); //[1]