Why the below is incorrect (about every() and Array.isArray)

Just solved steamroller,
not fully understand the below situation:

arr = [1, {}, [3, [[4]]]]


console.log(arr.every(!(Array.isArray)));//TypeError: false is not a function

.every takes a function as an argument. Putting the ! out from coerces the function pointer into a boolean.

1 Like

In my solution I used this:

arr.every(elem => (!Array.isArray(elem)))

I was trying to write it with less code, but this:


is also incorrect apparently.

It’s incorrect for the same reason. You need a function as the callback.