š Simply get the type of an object.
npm install prototypeof> š Simply get the type of an object.
_prototypeof_ is a simple function to get the type of an object by
using Object.prototype.toString on any given object. Usually, this
is always the best way to guess the type of an object since typeof
may return things not expected (Array and Null are consideredobject).
Furthermore, even when using Object.prototype.toString, thereās no
easy way to make custom types names. Thatās why I createdprototypeof.
The name may look misleading (weāre not actually getting the
prototype), but is
_etymologically_
correct. Which corresponds to ĻĻĻĻĪæ- (prÅto-) (most recent ancestor)
and type.
``javascript
const prototypeof = require('prototypeof');
class Type {
constructor() {
}
}
var type = new Type();
console.log(prototypeof(type)); // "Object"
console.log(prototypeof(Type, 'Type')); // "Type"
console.log(prototypeof(type)); // "Type"
`
* object: Any objects or primitives.type
* : _Optional_. If truthy, set the type name.String`.
* Return: A type name as a
This module and the whole directory is subject to
the MIT license.
I usually prefer the GPL license, but I donāt think itās big enough
care for that (and scare people like you).
Copyright (c) 2017 Etienne Prudāhomme