isPrimitive()
Syntax
function isPrimitive(object: unknown): object is primitive
Type guard that checks whether a value is a primitive.
Parameters | |
object
|
An object whose type isn’t known. |
Example
import { isPrimitive } from 'potence';
let value: unknown = 5;
if (isPrimitive(value)) {
// In this block, value has the type string | number | bigint | boolean | undefined | symbol.
// ...
}
Remarks
There are 6 primitive data types: string
, number
, bigint
, boolean
,
undefined
, and symbol
. See
MDN for more
information.
See primitive
.