Skip to content

isNumberArray

Jason Godesky edited this page Jul 11, 2026 · 2 revisions

isNumberArray is a type guard that lets Typescript know that the variable passed in is an array of numbers (number[]).

Note

This is just a wrapper for makeArrayGuard with isNumber, so the same caveat that isNumber rejects NaN also applies to isNumberArray.

Parameters

candidate: unknown

Supply any variable to test if it’s an array of numbers (number[]) or not.

Returns

A type predicate for an array of numbers (candidate is number[]).

Examples

import { isNumberArray } from '@revolutionarygamesco/common'

isNumberArray([1, 2, 3]) // true
isNumberArray([Infinity]) // true
isNumberArrat([1, 2, 3, NaN]) // false
isNumberArray(42) // false
isNumberArray('hello!') // false
isNumberArray({ a: 1 }) // false

Clone this wiki locally