My debugging work in IE ended today by finding that constructor.name
is undefined
.
I created the following simple code that reproduces the issu
I wrote this for my needs (acknowledging it may not be full-proof):
if (!Object.constructor.prototype.hasOwnProperty('name')) {
Object.defineProperty(Object.constructor.prototype, 'name', {
get: function () {
return this.toString().trim().replace(/^\S+\s+(\w+)[\S\s]+$/, '$1');
}
})
}
The regex being performed in the method is making an assumption that the 2nd non-whitespace group of characters IS the name of the constructor. This is a viable solution for the code that I'm working with, while this may not be full-coverage for all others' needs.