2 ms·
Offtopic follows: One thing that sucks about JS currently is the fact that you have to do Array.prototype.map.call(a, ...) instead of a.map, and even then you
by IgorPartola 16y ago
Offtopic follows:
One thing that sucks about JS currently is the fact that you have to do Array.prototype.map.call(a, ...) instead of a.map, and even then you don't have a guarantee that the correct function will execute. I know in ECMAScript 5 you can freeze properties of an object, but unless prototypes of basic methods come frozen, it's not ideal.
- brunoc 16y agoWhy exactly do you have to do that? Because some other unknown party could have overwritten the prototype with a new map function? If that's the case, none of the basic objects are safe, not just Array..
- IgorPartola 16y agoRight. My point exactly. In most cases this is not a problem and sometimes can be really nice: like when you want to add some profiling code, etc. However, this is also pretty terrible when it comes to large code bases or when you see libraries out there that modify prototypes of base objects.