Skip to content

Instantly share code, notes, and snippets.

@Erutan409
Last active May 7, 2022 01:05
Show Gist options
  • Save Erutan409/1fd2585bbc8ea5ee3652cbd332e33875 to your computer and use it in GitHub Desktop.
Save Erutan409/1fd2585bbc8ea5ee3652cbd332e33875 to your computer and use it in GitHub Desktop.
IE Javascript Constructor Name Polyfill
(function () {
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');
}
})
}
})();
@binarykitchen
Copy link

Thanks for the offer but no need, just realised core-js already has a polyfill. All good.

@Erutan409
Copy link
Author

Yeah, that was my first thought, too, actually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment