4 ms·
That will break with > Uncaught TypeError: Cannot convert undefined or null to object because `myObjectArr.at` doesn't bind `this` to `myObjectArr`. When the
by inbx0 5y ago
That will break with
> Uncaught TypeError: Cannot convert undefined or null to object
because `myObjectArr.at` doesn't bind `this` to `myObjectArr`. When the internals of `map` call the `at` function, `this` is just `undefined` instead of the original array and it'll throw.
Luckily Array.prototype.map takes a second argument just for this purpose
indices.map(myObjectArr.at, myObjectArr)
- antris 5y agoOh wow, I had to try it to make sure. I can't believe how broken the fundamentals of JS are. There should really be a whole new standard library made from ground up without `this`, mutability and all the other legacy stuff.
- deleted 5y ago[deleted]