I just came across this code for classList polyfill , and I don't understand why the developer decided to do the following:
var protoProp = "prototype";
... later in code ...
ClassList[protoProp] = [];
What happened to ClassList.prototype = []? I can’t think of why they will do it. What am I missing?
ClassList.prototype = []
It looks to minimize where this value can be converted to
ClassList[v]=[];
but not
ClassList.prototype = [];
The variable protoPropuses several places instead prototypeand saves only a few bytes
protoProp
prototype
, ,
arr.length ===> arr["length"]; str.replace("a","") ===> str["replace"]("a",""); Element.prototype.colorize ===> Element["prototype"]["colorize"]
length, replace, prototype, colorize , .
length
replace
colorize
Source: https://habr.com/ru/post/1658341/More articles:Использование переменных среды Docker в приложении Angular2 - dockerРасположение источника класса - rubyHow to implement a factory that automatically finds a strategy - c #Find max for each group with dplyr in R - rdocker-compose volumes are not mounted on host directories - dockerWeak characters and dlopen () with clang vs. gcc - gccSorting with Pandas does not return the desired result - pythonSolr не принимает запросы с точкой - luceneag-grid with one column, expand the column to the width of the grid - ag-gridType of mismatch to understand: getting a “product using Serializable” - yieldAll Articles