How to detect array equality in JavaScript?

后端 未结 4 1441
一个人的身影
一个人的身影 2020-12-16 19:21

There are two arrays in JavaScript, they are both in the following format:

[{\'drink\':[\'alcohol\', \'soft\', \'hot\']}, {\'fruit\':[\'apple\', \'pear\']}];         


        
4条回答
  •  有刺的猬
    2020-12-16 19:59

    You can try this JSON.stringify(array1)===JSON.stringify(array2); if you want the order also to be identical in both the arrays.

提交回复
热议问题