|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
947 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Checks whether a value is a JavaScript primitive.
|
|---|
| 3 | * JavaScript primitives include null, undefined, strings, numbers, booleans, symbols, and bigints.
|
|---|
| 4 | *
|
|---|
| 5 | * @param {unknown} value The value to check.
|
|---|
| 6 | * @returns {value is
|
|---|
| 7 | * null
|
|---|
| 8 | * | undefined
|
|---|
| 9 | * | string
|
|---|
| 10 | * | number
|
|---|
| 11 | * | boolean
|
|---|
| 12 | * | symbol
|
|---|
| 13 | * | bigint} Returns true if `value` is a primitive, false otherwise.
|
|---|
| 14 | *
|
|---|
| 15 | * @example
|
|---|
| 16 | * isPrimitive(null); // true
|
|---|
| 17 | * isPrimitive(undefined); // true
|
|---|
| 18 | * isPrimitive('123'); // true
|
|---|
| 19 | * isPrimitive(false); // true
|
|---|
| 20 | * isPrimitive(true); // true
|
|---|
| 21 | * isPrimitive(Symbol('a')); // true
|
|---|
| 22 | * isPrimitive(123n); // true
|
|---|
| 23 | * isPrimitive({}); // false
|
|---|
| 24 | * isPrimitive(new Date()); // false
|
|---|
| 25 | * isPrimitive(new Map()); // false
|
|---|
| 26 | * isPrimitive(new Set()); // false
|
|---|
| 27 | * isPrimitive([1, 2, 3]); // false
|
|---|
| 28 | */
|
|---|
| 29 | declare function isPrimitive(value: unknown): value is null | undefined | string | number | boolean | symbol | bigint;
|
|---|
| 30 |
|
|---|
| 31 | export { isPrimitive };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.