is2DArray
This is the shape Range#getValues returns and Range#setValues expects: rows holding cells. is2DArray answers only the shape question — whether the rows all have the same length is isConsistent2DArray.
An empty array is not two-dimensional here: there are no rows to examine, and treating [] as a matrix is what lets an empty result slip through into a setValues call that then fails. Nothing else about the elements is inspected, so a matrix of mixed types passes.
As a TypeScript type predicate it narrows the value to Array<Array<unknown>> inside the branch.
Parameters
Parameter | Type | Description |
|---|---|---|
|
| The value to check. |
Returns
boolean — true if the value is a non-empty array and every element of it is an array; otherwise false.
In TypeScript the guard narrows arr to Array<Array<unknown>> inside the branch.
Examples
What counts as two-dimensional
Guarding a value that may be a matrix
See also
isConsistent2DArray— adds the uniform row length check.non2DArray— the same test, negated.require2DArray— throws instead of answering.
Source
This documentation was generated with AI (Claude) from the library's source code.