re: Demystifying Array.prototype.flat VIEW POST


I'm nitpicking here, but

arr.flat(1) === arr.flat()

is false.

flat returns a new array and since objects (arrays) are compared by reference, any comparison of two arrays located in different memory slots will always return false.


Thanks for catching that.
That was me throwing it in really quick when someone asked me to make that distinction clear. Shouldn't have used code highlighting/syntax to explain it. I'll adjust!

Code of Conduct Report abuse