isPrimitive - Node documentation
function isPrimitive

Usage in Deno

import { isPrimitive } from "node:util";
isPrimitive(object: unknown): boolean
Deprecated

Since v4.0.0 - Use (typeof value !== 'object' && typeof value !== 'function') || value === null instead.

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

const util = require('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