Skip to content
On this page

@shaggytools/nhtsa-api-wrapper - v3.0.4 / Exports / utils/getTypeof

Module: utils/getTypeof

Table of contents

Functions

Functions

getTypeof

getTypeof(value): string

Gets type of value using Object.prototype.toString.call(value).

Why? Because typeof is not reliable for all types of values.

Object.prototype.toString gives more accurate results in the case someone has used an object wrapper for primitive data types such as new Number() or new String(). It will also accurately recognize any Error types, Error, TypeError, etc., as 'error'.

Parameters

NameTypeDescription
valueunknownAny kind of value (string, object, array, function, etc).

Returns

string

  • Type of value, normalized to a lowercase string.

Defined in

utils/getTypeof.ts:18

Released under the MIT License.