Angularjs angular equals function
In AngularJS, the angular.equals()
function is used to compare the equality of two objects.
Syntax:
refer to:theitroad.comangular.equals(obj1, obj2);
Where obj1
and obj2
are the two objects that need to be compared.
The angular.equals()
function compares the properties of the two objects and their values recursively, and returns true
if they are equal, and false
otherwise.
For example, let's say we have two objects:
var obj1 = { name: "John", age: 30, address: { city: "New York", state: "NY" } }; var obj2 = { name: "John", age: 30, address: { city: "New York", state: "NY" } };
We can compare the two objects using angular.equals()
like this:
var result = angular.equals(obj1, obj2);
In this example, result
will be true
because obj1
and obj2
have the same properties and values. If any of the properties or values are different, the angular.equals()
function will return false
.