es-toolkit/docs/reference/predicate/isJSONArray.md
knott ded56755f3
Some checks failed
CI / codecov (push) Has been cancelled
Release / release (push) Has been cancelled
feat(isJSONObject, isJSONValue, isJSONArray): Implement isJSONObject, isJSONValue, isJSONArray (#563)
* feat:init

* feat

* fix:use prettier

* feat(isPlainObject): Update signature of isPlainObject

* feat: Add isJSONValue, isJSONArray, and refactor isJSONObject

* remove from functions

* docs: Update docs

* docs: Update docs

* docs: Update docs

* docs: Update docs

* docs: Update docs

* docs: Update docs

* docs: Update docs

---------

Co-authored-by: Sojin Park <raon0211@gmail.com>
Co-authored-by: Sojin Park <raon0211@toss.im>
2024-09-29 20:42:50 +09:00

642 B

isJSONArray

Checks if a given value is a valid JSON array.

A valid JSON array is defined as an array where all items are valid JSON values.

Signature

function isJSONArray(value: unknown): value is any[];

Parameters

  • value (unknown): The value to check.

Returns

(value is any[]): True if the value is a valid JSON array, otherwise false.

Examples

console.log(isJSONArray([1, 2, 3])); // true
console.log(isJSONArray(['string', null, true])); // true
console.log(isJSONArray([1, 2, () => {}])); // false
console.log(isJSONArray('not an array')); // false