function.name not supported in IE.

前端 未结 5 1024
面向向阳花
面向向阳花 2020-11-29 10:01

Lately I\'ve become a huge fan of the function.name property.

For example, I\'ve written a function for extending prototypes.

It works in the w

5条回答
  •  野性不改
    2020-11-29 10:54

    Old question, and I don't know if this works on a native IE 7 & 8 browser (I'm using the developer tools emulator), but I've given functions a name property on the constructor for gag inducing IE code before....

    function sayMyName(func){
        var name=func.name || func.constructor.name
        alert(name);
    
    }
    
    var ieGivesMeNightTerrors=function(){
        //there there, these ugly workarounds aren't your fault
    };
    ieGivesMeNightTerrors.constructor.name=ieGivesMeNightTerrors;
    sayMyName(myFunc);
    

提交回复
热议问题