Array.isArrayintermediateconst mixed = [1, 'a', [2, 3], {b: 4}, [5]]
mixed.filter(Array.isArray) // β [[2, 3], [5]]Pass Array.isArray as a filter callback to extract only the array elements from a mixed collection.
Array.isArray is often used as a predicate in .filter() to pull only array values out of a mixed collection.
Challenge: Implement keepOnlyArrays that takes an array of unknown values and returns only the elements that are themselves arrays.
keepOnlyArrays([1, [2], 'hi', [3, 4], null]) // β [[2], [3, 4]]
keepOnlyArrays([1, 2, 3]) // β []