Skip to content

isSpecialObject

Determines if a value is a special object that should not have its properties compared deeply. Special objects include: Date, Function, Promise, Observable, RegExp, Error, Map, Set, WeakMap, WeakSet, etc.

Available since v2.0.0

import { isSpecialObject } from '@helpers4/guard';
isSpecialObject(value: unknown): boolean
ParameterTypeDescription
valueunknownThe value to check

boolean — true if the value is a special object, false otherwise

Returns true for built-in objects like Date, Map, Set, RegExp, etc.

isSpecialObject(new Date())     // => true
isSpecialObject(new Map())      // => true
isSpecialObject(/regex/)        // => true

Returns false for plain objects and arrays.

isSpecialObject({ a: 1 })  // => false
isSpecialObject([1, 2])    // => false

View source on GitHub