isPrimitive es-toolkit
Checks if a given value is a JavaScript primitive.
Usage
isPrimitive(value)
Use isPrimitive when you want to check if a value is a JavaScript primitive. JavaScript primitives include null, undefined, strings, numbers, booleans, symbols, and BigInt. It's useful for distinguishing from reference types like objects or functions.
It's useful when implementing deep copy logic.
You can use it as a type guard to write safe code.
You can distinguish wrapper objects like String, Number, Boolean from primitive values.
Parameters
The value to check if it's a JavaScript primitive.
Returns
Returns true if the value is a primitive, false otherwise.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.