Created
June 23, 2016 07:27
-
-
Save rkaw92/2ce4475733a017507c97f24546090774 to your computer and use it in GitHub Desktop.
A gist that shows that no method of object type detection is infallible in ECMAScript...
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
Object.prototype.toString.call(new Date()); // '[object Date]' | |
// Now to have some fun: | |
const suspiciousDate = new Date(); | |
suspiciousDate[Symbol.toStringTag] = 'window'; | |
Object.prototype.toString.call(suspiciousDate); // wut! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment