Skip to content

getTypeOf

type: function

The getTypeof function extends native typeof with more precise distinctions.

Usage

import { getTypeof } from '@mustib/utils';
getTypeof('x'); // string
getTypeof(NaN); // NaN
getTypeof([]); // array
getTypeof(new Uint8Array()); // buffer
getTypeof(new Date('invalid')); // invalid_date

Definition

function getTypeof(value: any): string { }

Parameters

  1. value
    type value = any;
    • Value to inspect.

Returns

type T = string;
  • Possible values include:
    • `buffer`, `string`, `boolean`, `undefined`, `function`, `symbol`.
    • `number`, `NaN`, `array`, `null`, `invalid_date`, `date`, `object`, `unknown`.