W3cubDocs

/Angular.js 1.8

Improve this Doc View Source angular.equals

  1. function in module ng

Overview

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 (===).

Usage

angular.equals(o1, o2);

Arguments

Param Type Details
o1 *

Object or value to compare.

o2 *

Object or value to compare.

Returns

boolean

True if arguments are equal.

Example

© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.
https://code.angularjs.org/1.8.2/docs/api/ng/function/angular.equals