Skip to main content
function isPrimitive
isPrimitive(object: unknown): boolean
Deprecated

Returns true if the given object is a primitive type. Otherwise, returnsfalse.

import util from 'node:util';

util.isPrimitive(5);
// Returns: true
util.isPrimitive('foo');
// Returns: true
util.isPrimitive(false);
// Returns: true
util.isPrimitive(null);
// Returns: true
util.isPrimitive(undefined);
// Returns: true
util.isPrimitive({});
// Returns: false
util.isPrimitive(() => {});
// Returns: false
util.isPrimitive(/^$/);
// Returns: false
util.isPrimitive(new Date());
// Returns: false

Parameters

object: unknown

Return Type

boolean
Back to top