Javascript redefine and override existing function body

后端 未结 8 2070
难免孤独
难免孤独 2020-12-24 03:12

I am wondering can we still change the function body once it is constructed ?

     var O = function(someValue){
           this.hello = function(){
                 


        
8条回答
  •  滥情空心
    2020-12-24 03:55

    Override method refreshEditor for created instance:

    var cp = hot1.getPlugin('comments');
    cp.refreshEditor = (function (original) {
      return function (force) {
        //do something additional
        if(console) {
          console.log('test!!!!!!!!!');
          console.log(force)
        }
        original.call(cp, force);
      }
    })(cp.refreshEditor);
    

提交回复
热议问题