The type utilities module provides functions for checking and identifying JavaScript value types, including enhanced type detection for arrays, elements, and null values.
Returns the type of a value as a string, with enhanced detection for arrays, DOM elements, and null.
import { typeOf } from '../src/utils/type.js';
typeOf('hello'); // "string"
typeOf(42); // "number"
typeOf([1, 2, 3]); // "array"
typeOf(null); // "null"
typeOf(document.body); // "element" (in browser)
Checks if a value is of a specific type.
import { isType } from '../src/utils/type.js';
isType('hello', 'string'); // true
isType([1, 2], 'array'); // true
isType(null, 'null'); // true
isType(42, 'string'); // false