node-lib

@wtasnorg/node-lib


@wtasnorg/node-lib / isPrimitive

Function: isPrimitive()

isPrimitive(val): boolean

Defined in: src/primitive.ts:22

Check whether a value is a JavaScript primitive (null, boolean, number, string, symbol, bigint, or undefined).

Parameters

val

unknown

The value to test.

Returns

boolean

true when val is a primitive.

Example

isPrimitive(42);        // true
isPrimitive("hello");   // true
isPrimitive({});         // false
isPrimitive(null);       // true