关于在underscore.js中optimizeCb函数下的不解?

大家好,我在看源码时发现optimizeCb函数,第一个判断条件if (context === void 0) return func; 其中func,我打印了下如下:

 ƒ (name) {
  _['is' + name] = function(obj) {
    return toString.call(obj) === '[object ' + name + ']';
  };
}
   ƒ (name) {
    var func = _[name] = obj[name];
    _.prototype[name] = function() {
      var args = [this._wrapped];
      push.apply(args, arguments);
      return result(this, func.apply(_, args));
    ƒ (name) {
      var method = ArrayProto[name];
      _.prototype[name] = function() {
        var obj = this._wrapped;
        method.apply(obj, arguments);
        if ((name === 'shift' || name === 'splice') && obj.leng…
    ƒ (name) {
      var method = ArrayProto[name];
      _.prototype[name] = function() {
        return result(this, method.apply(this._wrapped, arguments));
      };
    }
    ƒ alert() { [native code] }

总共是五个函数:关于这五个函数不知甚解,所以劳烦各位,知道给讲解下,打扰了。

阅读 1.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题