Skip to content

Instantly share code, notes, and snippets.

@ottonascarella
Last active May 18, 2017 04:01
Show Gist options
  • Save ottonascarella/974eea02bc6cf68daeaaed2f999e59bd to your computer and use it in GitHub Desktop.
Save ottonascarella/974eea02bc6cf68daeaaed2f999e59bd to your computer and use it in GitHub Desktop.
get type from javascript value
function type (v) {
if (typeof v.constructor['@@type'] === 'string') return v.constructor['@@type'];
if (isNaN(v)) return 'NaN';
return ({}).toString.call(v).replace(/\[object\s|\]/g, '');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment