Javascript比较两个数组是否相等(存在重复元素)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/WRian_Ban/article/details/70570256
  • 首先判断长度
  • 再排序
  • 转化为字符串
  • 做比较
if (Arr1.length!=Arr2.length) {
     return true;
 }else{
     if (Arr1.sort().toString()!= Arr2.sort().toString()) {
         return true;
     };
 }

猜你喜欢

转载自blog.csdn.net/WRian_Ban/article/details/70570256