Pass in a value and get a boolean telling you if the value is a plain object, a custom class instance, or an object with a null prototype.
This function returns false for arrays, functions, and built-in object types like Date, RegExp, Map, and Set.
import*as
import _
_from'radashi'
class
classData
Data {}
import _
_.
functionisObject(value:unknown):valueisobject
Returns true if value is a plain object, a class instance
(excluding built-in classes like Date/RegExp), or an
Object.create(null) result. Objects from other realms are
also supported.
Use this as a TypeScript type guard only when the input is known to
be either an object accepted by isObject or a non-object value. The
object type in TypeScript also includes arrays, functions, dates,
maps, sets, and other object-like values that isObject may reject
at runtime.
Returns true if value is a plain object, a class instance
(excluding built-in classes like Date/RegExp), or an
Object.create(null) result. Objects from other realms are
also supported.
Use this as a TypeScript type guard only when the input is known to
be either an object accepted by isObject or a non-object value. The
object type in TypeScript also includes arrays, functions, dates,
maps, sets, and other object-like values that isObject may reject
at runtime.
Provides functionality common to all JavaScript objects.
Object.
ObjectConstructor.create(o: object |null): any (+1 overload)
Creates an object that has the specified prototype or that has null prototype.
@param ― o Object to use as a prototype. May be null.
create(null)) // => true
import _
_.
functionisObject(value:unknown):valueisobject
Returns true if value is a plain object, a class instance
(excluding built-in classes like Date/RegExp), or an
Object.create(null) result. Objects from other realms are
also supported.
Use this as a TypeScript type guard only when the input is known to
be either an object accepted by isObject or a non-object value. The
object type in TypeScript also includes arrays, functions, dates,
maps, sets, and other object-like values that isObject may reject
at runtime.
Returns true if value is a plain object, a class instance
(excluding built-in classes like Date/RegExp), or an
Object.create(null) result. Objects from other realms are
also supported.
Use this as a TypeScript type guard only when the input is known to
be either an object accepted by isObject or a non-object value. The
object type in TypeScript also includes arrays, functions, dates,
maps, sets, and other object-like values that isObject may reject
at runtime.
Returns true if value is a plain object, a class instance
(excluding built-in classes like Date/RegExp), or an
Object.create(null) result. Objects from other realms are
also supported.
Use this as a TypeScript type guard only when the input is known to
be either an object accepted by isObject or a non-object value. The
object type in TypeScript also includes arrays, functions, dates,
maps, sets, and other object-like values that isObject may reject
at runtime.
Returns true if value is a plain object, a class instance
(excluding built-in classes like Date/RegExp), or an
Object.create(null) result. Objects from other realms are
also supported.
Use this as a TypeScript type guard only when the input is known to
be either an object accepted by isObject or a non-object value. The
object type in TypeScript also includes arrays, functions, dates,
maps, sets, and other object-like values that isObject may reject
at runtime.
Returns true if value is a plain object, a class instance
(excluding built-in classes like Date/RegExp), or an
Object.create(null) result. Objects from other realms are
also supported.
Use this as a TypeScript type guard only when the input is known to
be either an object accepted by isObject or a non-object value. The
object type in TypeScript also includes arrays, functions, dates,
maps, sets, and other object-like values that isObject may reject
at runtime.
This is a good fit for accepting either an options object or a primitive shorthand.
import*as
import _
_from'radashi'
type
typeOptions= {
foo?:string;
}
Options= {
foo?: string
foo?:string }
declarelet
let value:string|Options|undefined
value:
typeOptions= {
foo?:string;
}
Options|string|undefined
const
constoptions:Options
options:
typeOptions= {
foo?:string;
}
Options=
import _
_.
functionisObject(value:unknown):valueisobject
Returns true if value is a plain object, a class instance
(excluding built-in classes like Date/RegExp), or an
Object.create(null) result. Objects from other realms are
also supported.
Use this as a TypeScript type guard only when the input is known to
be either an object accepted by isObject or a non-object value. The
object type in TypeScript also includes arrays, functions, dates,
maps, sets, and other object-like values that isObject may reject
at runtime.
If a union can contain arrays, functions, or special objects, narrow those cases directly instead of starting with _.isObject.
import*as
import _
_from'radashi'
type
typeOptions= {
foo?:string;
}
Options= {
foo?: string
foo?:string }
declareconst
constvalue:Options| (() =>Options) |Options[]
value:
typeOptions= {
foo?:string;
}
Options| (() =>
typeOptions= {
foo?:string;
}
Options) |
typeOptions= {
foo?:string;
}
Options[]
if (
import _
_.
functionisObject(value:unknown):valueisobject
Returns true if value is a plain object, a class instance
(excluding built-in classes like Date/RegExp), or an
Object.create(null) result. Objects from other realms are
also supported.
Use this as a TypeScript type guard only when the input is known to
be either an object accepted by isObject or a non-object value. The
object type in TypeScript also includes arrays, functions, dates,
maps, sets, and other object-like values that isObject may reject
at runtime.