Skip to main content
isPrimitive - node__util.d.ts - Node documentation
function isPrimitive

Usage in Deno

```typescript import { isPrimitive } from "node:node__util.d.ts"; ```
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, returns`false`. ```js 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