javascript add prototype method to all functions?

前端 未结 4 893
星月不相逢
星月不相逢 2021-02-05 09:54

Is there a way to add a method to all javascript functions without using the prototype library?

something along the lines of :

Function.prototype.methodN         


        
4条回答
  •  深忆病人
    2021-02-05 10:32

    function one(){
        alert(1);
    }
    function two(){
        alert(2);
    }
    
    var myFunctionNames = ["one", "two"];
    
    for(var i=0; i

提交回复
热议问题