# Function equals

- equals(o1: any, o2: any): boolean

  Determines if two objects or two values are equivalent. Supports value types, regular expressions, arrays and objects.

  Two objects or values are considered equivalent if at least one of the following is true:

  - Both objects or values pass `===` comparison.
  - Both objects or values are of the same type and all of their properties are equal by comparing them with `angular.equals`.
  - Both values are NaN. (In JavaScript, NaN == NaN => false. But we consider two NaN as equal)
  - Both values represent the same regular expression (In JavaScript, /abc/ == /abc/ => false. But we consider two regular expressions as equal when their textual representation matches).

  During a property comparison, properties of `function` type and properties with names that begin with `$` are ignored.

  Scope and DOMWindow objects are being compared only by identify (`===`).

  #### Parameters

  - o1: any

    Object or value to compare.

  - o2: any

    Object or value to compare.

  #### Returns boolean

  True if arguments are equal.

  #### Example

      <example module="equalsExample" name="equalsExample">
          <file name="index.html">
           <div ng-controller="ExampleController">
             <form novalidate>
               <h3>User 1</h3>
               Name: <input type="text" ng-model="user1.name">
               Age: <input type="number" ng-model="user1.age">

               <h3>User 2</h3>
               Name: <input type="text" ng-model="user2.name">
               Age: <input type="number" ng-model="user2.age">

               <div>
                 <br/>
                 <input type="button" value="Compare" ng-click="compare()">
               </div>
               User 1: <pre>{{user1 | json}}</pre>
               User 2: <pre>{{user2 | json}}</pre>
               Equal: <pre>{{result}}</pre>
             </form>
           </div>
         </file>
         <file name="script.js">
             angular.module('equalsExample', []).controller('ExampleController', ['$scope', function($scope) {
               $scope.user1 = {};
               $scope.user2 = {};
               $scope.compare = function() {
                 $scope.result = angular.equals($scope.user1, $scope.user2);
               };
             }]);
         </file>
       </example>

  - Defined in src/shared/utils.js:519