Skip to content

Instantly share code, notes, and snippets.

@yorickshan
Created July 17, 2019 03:41
Show Gist options
  • Save yorickshan/9027d225c37f6f958d3e2812fe9ef65f to your computer and use it in GitHub Desktop.
Save yorickshan/9027d225c37f6f958d3e2812fe9ef65f to your computer and use it in GitHub Desktop.

Object.prototype.toString()

var toString = Object.prototype.toString;

toString.call(new Date); // [object Date]
toString.call(new String); // [object String]
toString.call(Math); // [object Math]

//Since JavaScript 1.8.5
toString.call(undefined); // [object Undefined]
toString.call(null); // [object Null]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment