Check Equality in javascript objects - Javascript Object

Javascript examples for Object:Object Operation

Description

Check Equality in javascript objects

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {//w  w w .  j ava  2 s .com
function Foo(){}
var foo1 = new Foo();
var foo2 = new Foo();

console.log(foo1===foo2); // false

function updateFoo1(foo)
{
    if (foo === foo1)
    {
        //code for processing
        return true;
    }
    else return false;
}

console.log(updateFoo1(foo1)); // true
console.log(updateFoo1(foo2)); // false

    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials