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