Comparing two or more Javascript Objects using Method

Javascript method compares two or more objects and returns true if both are same or returns false. The checking is not just limited to type checking or checking of value it goes beyond and checks its instance or the objects are the same.

Syntax, object2, object3...);

The Javascript method returns boolean value.

var arr = [1,2,3];
var copy = arr;

//Console Output

Comparing all objects, string, and numbers with method.

var str1 = "Javascript";
var str2 = "Javascript";

console.log(,str2)); // true

var num1 = 100.25;
var num2 = 100.25;
console.log(,num2)); // true

console.log(,null)); // true

var arr1 = [];
var arr2 = [];
console.log(,arr2)); // false

var arr3 = arr1;
console.log(,arr3)); // false

var obj1 = {};
var obj2 = {};
console.log(,obj2)); // false

var obj3 = obj1;
console.log(,obj3)); // true

Comparing multiple objects

var obj1 = {};
var obj2 = {};
var obj3 = obj1;

//Console Output

We can compare multiple objects and the checking ours in AND the logic that is to return true all for the above 3 objects these objects must be the same if one object is different this does not match with other objects and the method returns false.


So it’s time to say bye we have come to the end of our post on Comparing two or more Javascript Objects using Method.If you like our content then please do share it and comment to clarify your doubts.

Related Posts

Review Date
Reviewed Item
Comparing two or more Javascript Objects using Method
Author Rating
Software Name
Javascript Programming
Software Name
Windows Os, Mac Os, Ubuntu Os
Software Category
Web Development