Skip to main content

isPrimitive

Checks if the given value is primitive. Primitive Types:

  • number
  • string
  • boolean
  • symbol
  • bigint
  • undefined
  • null

API

function isPrimitive(value: any): boolean;

Usage

import { isPrimitive } from '@feedzai/js-utilities';

isPrimitive(undefined)
// true

isPrimitive(null)
// true

isPrimitive(123)
// true

isPrimitive("hello")
// true

isPrimitive(true)
// true

isPrimitive(Symbol())
// true

isPrimitive(BigInt(123))
// true

isPrimitive([1, 2, 3])
// false

isPrimitive({ key: "value" })
// false

isPrimitive(() => {})
// false