My debugging work in IE ended today by finding that constructor.name
is undefined
.
I created the following simple code that reproduces the issu
This is an improvisation from Oliver's answer.
Instead of using regex, this method will parse the string once and save it to the scope to avoid performance problem if it's called more than once.
if(Function.prototype.name === undefined){
Object.defineProperty(Function.prototype, 'name', {
get:function(){
if(!this.__name)
this.__name = this.toString().split('(', 1)[0].split(' ')[1];
return this.__name;
}
});
}