The questioner did not say it is a simple array; if the array elements include Object, etc., then the above answer will basically fail. Then the problem actually becomes how to judge that two Objects are equal, and then it involves recursion... In short, it is not that simple, so I won’t go into details about the claw machine code.
Judging that all are equal is equivalent to judging that one of them is not equal,
The questioner did not say it is a simple array; if the array elements include Object, etc., then the above answer will basically fail. Then the problem actually becomes how to judge that two Objects are equal, and then it involves recursion... In short, it is not that simple, so I won’t go into details about the claw machine code.
Isn’t this something that can be solved with just one cycle?
If you want to consider objects, you can refer to Lodash’s isEqual
Only simple types are considered:
How about I show off my wits?