Что делает MooTools 'Function.prototype.overloadSetter ()?
Я просматриваю источник MooTools, чтобы попытаться понять его.implement()
а также.extend()
коммунальные услуги.
Определение каждого относится к функции, определенной следующим образом:
var enumerables = true;
for (var i in {toString: 1}) enumerables = null;
if (enumerables) enumerables = ['hasOwnProperty', 'valueOf', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'constructor'];
Function.prototype.overloadSetter = function(usePlural){
var self = this;
return function(a, b){
if (a == null) return this;
if (usePlural || typeof a != 'string'){
for (var k in a) self.call(this, k, a[k]);
if (enumerables) for (var i = enumerables.length; i--;){
k = enumerables[i];
if (a.hasOwnProperty(k)) self.call(this, k, a[k]);
}
} else {
self.call(this, a, b);
}
return this;
};
};
Тем не менее, мне трудно понять, что он делает.
Можете ли вы объяснить, как эта функция работает и что она делает?