tagOf.js
typeof alternative:
- robust and well tested
- works with user-defined classes
- works with node, AMD and all browsers, including legacy ones like IE6
// tagOf( value:any ): string // 'null' // 'undefined' // 'number' // 'number' // 'string' // 'string' // 'boolean' // 'boolean' // 'boolean' // 'boolean' // 'object' // 'array' // 'function' // 'date' // 'regexp' // 'regexp' // ES6 additions // 'symbol' // 'symbol' // 'set' // 'weakset' // 'map' // 'weakmap' // user-defined classes {} {} // 'circle' // 'square' // 'object' - does not work with anonymous class
Install
Node:
$ npm install --save tagOf
const tagOf =
Browser:
tagOf will register itself as an anonymous AMD module if AMD loader presents, otherwise it is defined as a browser global named unsuprisingly,
tagOf
Caveats
Does not work with Error
objects.