相关疑难解决方法(0)

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 …
Run Code Online (Sandbox Code Playgroud)

javascript mootools

15
推荐指数
1
解决办法
1273
查看次数

标签 统计

javascript ×1

mootools ×1