2 ms·
if (array.at) { explode(); } Adding the at function would break the above code which depends on array.at being undefined.
by charcircuit 4y ago
if (array.at) {
explode();
}
Adding the at function would break the above code which depends on array.at being undefined.
- spartanatreyu 4y agoAnd extending javascript's built-in objects has been considered bad practice since at least 2007. Before that point, browser environments were so different that you needed to write code per-browser. Those theoretical concerns didn't really matter since in-practice you were essentially coding the same app in different scripting languages.
- egeozcan 4y ago> extending javascript's built-in objects has been considered bad practice since at least 2007 Totally. It's just extending the prototype that causes the problem though, not extending from (class myclass extends array). This causes a lot of confusion among new js devs so I underline this on every opportunity.
- egeozcan 4y agoThey test a lot of websites before introducing new methods. Something somewhere may break but it's very unlikely and this pragmatic approach allows progress. This is also why the language got Array.prorotype.flat instead of flatten (flatten was breaking an old version of a popular library called Mootools): https://developer.chrome.com/blog/smooshgate/ https://developer.chrome.com/blog/smooshgate/