Last active
May 7, 2022 01:05
-
-
Save Erutan409/1fd2585bbc8ea5ee3652cbd332e33875 to your computer and use it in GitHub Desktop.
IE Javascript Constructor Name Polyfill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 I suppose I could.
Thanks for the offer but no need, just realised core-js already has a polyfill. All good.
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
Nice. Why not put this in a new npm package?