I can see why you’d need to loop if you had very complicated arrays, possible containing objects or deep nesting.
However, in such a case I would probably have to carefully examine whether comparing two such arrays was actually the best solution to whatever problem I was actually trying to solve. I suspect there are very few occasions upon which such a comparison is necessary, but maybe I’m just not sufficiently imaginative to think of them
Remember that with non-primitive data types, that variable doesn’t compare the data itself but the address of the memory where the data is stored. When you compare the variables you are asking if they point to the same memory. In this case it is two different memory locations (that contain the same data) so the addresses are different.
Either of the two solutions offered will work. I don’t know know if one is better than the other - we’d have to test them.