Array.isArrayintermediateconst matrix = [[1, 2], [3, 4]]
matrix.every(Array.isArray) // β true (all rows are arrays)Use Array.isArray with every() to confirm all elements of an array are themselves arrays.
Using Array.isArray together with .every() lets you verify that every element of an array is itself an array β a useful validation when working with matrix data.
Challenge: Implement isArrayOfArrays that returns true only when the input is an array and every element is also an array.
isArrayOfArrays([[1, 2], [3, 4]]) // β true
isArrayOfArrays([[1], 2, [3]]) // β false
isArrayOfArrays([]) // β true (vacuously true)