Examples of the output of classof()
:
// Standard JS objects
> classof()
'undefined'
> getclasses(undefined, [,][0], window.notDefined)
'undefined'
> classof(null)
'null'
> classof({})
'object'
> classof([])
'array'
> getclasses(function() {}, classof, Object, escape, parseInt)
'function, function, function, function, function'
> (function() { return classof(arguments); })()
'arguments'
> getclasses(new Error, new TypeError, new SyntaxError)
'error, error, error'
> getclasses(true, false)
'boolean, boolean'
> getclasses(4, 1.2, -6, 1.7e666, Infinity, NaN)
'number, number, number, number, number, number'
> classof('')
'string'
> classof(/./)
'regexp'
> classof(new Date)
'date'
> classof(JSON)
'json'
> classof(Math)
'math'
// Browser objects
> classof(window)
'window'
> classof(document)
'document'
> classof(document.body)
'htmlbodyelement'
> getclasses(document.images, document.querySelectorAll('img'))
'htmlcollection, nodelist'
> classof(location)
'location'
// Node.js objects
> classof(global)
'global'
> classof(module)
'object'
> classof(require)
'function'
> classof(process)
'process'
// New objects in ES6 Harmony (using node --harmony)
> classof(function*() { yield 0; })
'function'
> classof(new Set)
'set'
> classof(new Map)
'map'
> classof(new WeakMap)
'weakmap'