How to compare two arrays in node js?

前端 未结 7 1560
无人及你
无人及你 2021-01-12 07:42

I am having two arrays, how can i compare the two arrays at single shot.

   var arr1= [\"a\",\"b\",\"c\"];
   var arr2 = [\"a\",\"c\",\"d\"]

   if(arr1 == a         


        
相关标签:
7条回答
  • 2021-01-12 08:12

    I would make use of underscore for this.

    var same = (_.difference(arr1, arr2).length == 0)
    
    0 讨论(0)
提交回复
热议问题