AngularJS – equals() method

The equals() method in AngularJS basically checks if two objects or two values are equal or not. This method supports value types, regular expressions, arrays, and objects. It will return True if the reference objects passed inside the function are equal, else it will return False.

Syntax

angular.equals(value1, value2)

Example − Check if the reference objects are equal or not

Create a file "equals.html" in your Angular project directory and copy-paste the following code snippet.


   
      angular.equals()

      
   

   
      

         Welcome to Tutorials Points      

     

AngularJS | angular.equals()

     
         Input A:
         
         Input B:
         
         {{msg}}      
               

Output

To run the above code, just go to your file and run it as a normal HTML file. You will see the following output on the browser window.

Example − Check if the references are equal or not

Create a file "equals.html" in your Angular project directory and copy-paste the following code snippet.


   
      angular.equals()

      
   

   
      

         Welcome to Tutorials Point      

     
         Password:
                   
         
         Confirm Password:
         
         

Password matched

Password does not match

Output

To run the above code, just go to your file and run it as a normal HTML file. You will see the following output on the browser window.

Updated on: 2021-10-08T12:46:35+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements