isPrimitive() function
Determines whether a value is a JavaScript primitive.
Signature
export declare function isPrimitive(value: unknown): boolean;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
value |
unknown |
The value to test. |
Returns
boolean
true if the value is a primitive or null, false otherwise.
Remarks
In JavaScript, primitives are immutable values that are not objects: string, number, bigint, boolean, undefined, and symbol. This function also treats null as a primitive, following JavaScript's typeof behavior despite null being technically an object type.
Returns true for: string, number, bigint, boolean, undefined, symbol, and null.
Returns false for: objects, arrays, functions, and class instances.
Useful for distinguishing between value types and reference types when processing JSON data or validating configuration inputs.
Generated via tsdoc2docusaurus 1.3.0-pre by API Extractor/Documenter 7.55.2.