Checks whether an array has an exact length, narrowing the type to a fixed-length tuple.
Array whose length is compared.
Exact length to match; when equal, narrows arr to a fixed-length tuple type.
arr
true when arr.length equals length exactly.
true
arr.length
length
const values: number[] = [1, 2, 3];if (isLength(values, 3)) { // values: [number, number, number]}isLength(values, 2); // false Copy
const values: number[] = [1, 2, 3];if (isLength(values, 3)) { // values: [number, number, number]}isLength(values, 2); // false
Checks whether an array has an exact length, narrowing the type to a fixed-length tuple.