How to compare two json objects using angularjs?

I have two json objects

 $scope.car1={"Sedan":{"Audi":["A4","A3"]},"Hatchback":{"Maruthi":["Swift"]}}; 
  $scope.car2={"Hatchback":{"Maruthi":["Swift"]},"Sedan":{"Audi":["A3","A4"]}}; 

I want to compare these two objects. I tried the following code:

var a=angular.equals($scope.car1,$scope.car2);

Since it angular.equalsperforms a deep comparison, it also takes care of the data order. Is there a way to compare objects regardless of order?

+4
source share
2 answers

"Objects" have no order. angular.equalswill compare values ​​using their keys.

+2
source

" ", , :
= > , = > .

myEqual()

+1

Source: https://habr.com/ru/post/1614224/


All Articles