Created
January 25, 2017 23:31
-
-
Save getify/d15bcb82f96b971d47e4d971587f5c7d to your computer and use it in GitHub Desktop.
Make JavaScript Great Again
This file contains hidden or 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
| Object.defineProperty(Object.prototype,Symbol.toStringTag,{ | |
| get() { | |
| return JSON.stringify(this); | |
| }, | |
| set(v) { | |
| Object.defineProperty(Object.prototype,Symbol.toStringTag,{ | |
| value: v, | |
| enumerable: false, | |
| writable: true, | |
| configurable: true | |
| }); | |
| }, | |
| enumerable: false, | |
| configurable: true | |
| }); | |
| ({ a: 2, b: 3 }).toString(); // [object {"a":2,"b":3}] | |
| Object.prototype.toStringTag = "cool"; | |
| ({ a:2, b: 3 }).toString(); // [object cool] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment