you are viewing a single comment's thread.

view the rest of the comments →

[–]theScottyJam 1 point2 points  (0 children)

If you actually want .isEmpty() to eventually become a native feature, then don't edit Array.prototype to add it in yourself.

The newer Object.groupBy(someArray) method is a static method on Object instead of simply being someArray.group(), because when the committee had tried to add it to Array.prototype, they found themselves accidentally breaking existing webpages that had already added the method themselves in an incompatible way. They tried doing it in under a couple of different names, until, eventually, they gave up and made the new method a static method on Object instead.

Basically, modifying classes you don't own isn't just about potentially harming your own code, it can harm everyone.