I'm not writing to start or join a debate on the merits of using 
`Function.prototype` and `Array.prototype` in the aforementioned ways. I'm 
writing to confirm that they are in fact used, not just theoretically made up.

I have been writing about and teaching for several years usage of 
`Function.prototype` as a (convenience) no-op empty function and 
`Array.prototype` as a (convenience) default empty array (not to be mutated, 
obviously). The most recent case of me publicly talking about these techniques 
is in my recently published book "YDKJS: Types & Grammar":

https://github.com/getify/You-Dont-Know-JS/blob/master/types%20&%20grammar/ch3.md#prototypes-as-defaults

While I can't go back now and get at all those old code bases that I either 
consulted on or taught on in workshops, and though that code may unfortunately 
not show up in GitHub searches, I assure you that such code exists. Moreover, I 
have right now a local (non-GH, for certain reasons) fork of Esprima that I've 
been hacking on for about a year, and atm I have 34 occurrences in it of using 
`Array.prototype` as a shared empty default array for starting iterations, etc.

There is no debate of if it will break code, but rather if it's ok to break 
code since the numbers are sufficiently low. Please don't pretend this is just 
academic contrarianism at play.

Furthermore, I would posit that whatever evidence was used to roll back the 
`Function.prototype` change -- that is, people who use it as an empty no-op 
function -- would be the symmetric evidence, and the nearly identical mindset, 
to using `Array.prototype` as a default empty array. That is, I think there's 
at least a decent amount of correlation/overlap there.

However, I'm not seeing or finding the contra-argument of why it's so much 
better to justify making this breaking change, nor why it makes more sense to 
break `Array.prototype` usage but not `Function.prototype` usage.



--Kyle







_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to