Skip to content

Instantly share code, notes, and snippets.

@rkaw92
Created June 23, 2016 07:27
Show Gist options
  • Save rkaw92/2ce4475733a017507c97f24546090774 to your computer and use it in GitHub Desktop.
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...
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