【Web前端基础】js函数能复制吗

2021-01-15 10:25发布

5条回答
lemon
2021-01-19 15:36

可以的

Function.prototype.clone = function() {
   var fct = this;
   var clone = function() {
       return fct.apply(this, arguments);
   };
   clone.prototype = fct.prototype;
   for (property in fct) {
       if (fct.hasOwnProperty(property) && property !== 'prototype') {
           clone[property] = fct[property];
       }
   }
   return clone;};


一周热门 更多>