|
Last change
on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
754 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Checks if the given value is boolean.
|
|---|
| 3 | *
|
|---|
| 4 | * This function tests whether the provided value is strictly `boolean`.
|
|---|
| 5 | * It returns `true` if the value is `boolean`, and `false` otherwise.
|
|---|
| 6 | *
|
|---|
| 7 | * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
|
|---|
| 8 | *
|
|---|
| 9 | * @param {unknown} x - The Value to test if it is boolean.
|
|---|
| 10 | * @returns {x is boolean} True if the value is boolean, false otherwise.
|
|---|
| 11 | *
|
|---|
| 12 | * @example
|
|---|
| 13 | *
|
|---|
| 14 | * const value1 = true;
|
|---|
| 15 | * const value2 = 0;
|
|---|
| 16 | * const value3 = 'abc';
|
|---|
| 17 | *
|
|---|
| 18 | * console.log(isBoolean(value1)); // true
|
|---|
| 19 | * console.log(isBoolean(value2)); // false
|
|---|
| 20 | * console.log(isBoolean(value3)); // false
|
|---|
| 21 | *
|
|---|
| 22 | */
|
|---|
| 23 | declare function isBoolean(x: unknown): x is boolean;
|
|---|
| 24 |
|
|---|
| 25 | export { isBoolean };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.