Performing Equality and Identity Tests on Objects

The following code is performing Equality and Identity Tests on Objects.

 
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
</head>
<body>
  <script type="text/javascript">
    var myData1 = {
      name : "JavaScript",
      weather : "Good",
    };
    var myData2 = {
      name : "JavaScript",
      weather : "Good",
    };
    
    var myData3 = myData2;

    var test1 = myData1 == myData2;
    var test2 = myData2 == myData3;
    var test3 = myData1 === myData2;
    var test4 = myData2 === myData3;
    document.writeln("Test 1: " + test1 + " Test 2: " + test2);
    document.writeln("Test 3: " + test3 + " Test 4: " + test4);
  </script>
</body>
</html>
  
Click to view the demo
Home 
  JavaScript Book 
    Essential Types  

Object:
  1. The Object Type
  2. Enumerating an Object's Properties
  3. Adding and Deleting Properties and Methods
  4. Add new methods to an object
  5. Delete a property or method from an object
  6. Determine If an Object Has a Property
  7. Performing Equality and Identity Tests on Objects