Skip to content

isJSONArray

Checks whether a value is an array whose every element is a valid JSON value (see isJSONValue).

Available since v3.0.3

import { isJSONArray } from '@helpers4/guard';
// or, from the all-in-one package (same code, one install):
import { isJSONArray } from 'helpers4/guard';
isJSONArray(value: unknown): value is unknown[]
ParameterTypeDescription
valueunknownThe value to check

value is unknown[] — true if value is an array of JSON values

Checks that a value is an array whose every element is JSON-representable.

isJSONArray([1, 'two', null])
// => true
isJSONArray([1, undefined])
// => false

View source on GitHub