I need to compare two arrays. If I test if Object1==Object2 I am testing if the objects point to the same address in memory. I actually want to compare them based on their properties values. Let me show you what I mean.
I have a class in javascript:
function MyClass(var1,var2,var3)
{
this.var1 = var1;
this.var2 = var2;
this.var3 = var3;
}
Now I will be able to create a new object of that class as:
var myNewObject = new MyClass(1,"hello",3);
and I will be able to access the properties of that object as:
myNewObject.var2 = "New value";
I have two arrays:
var array1 = new Array();
var array2 = new Array();
both arrays are populated with MyClass objects. In other words if array1 has 3 elements I know that they will be of type MyClass meaning I could do something like: array1[2].var1 = foo
*I will like to compare array1 with array2 based on the values of their properties *
for example if
array1 = [ [1,"hello",4] , [0,"foo",5] ];
array2 = [ [0,"foo",5555] [1111,"hello",4]];
note: // [1,"hello",4] means a MyClass object with var1=1, var2="hello", var3 = 4
I will like to have a method that will tell me the changes. In this example var1 changed to 1111 and var3 changed from 5 to 5555.
I will probably be able to do it if I spend a lot of ours doing it. I am not to good at algorithms and maybe there is a simple way of doing it.
edit
I will like to know the changes that I will have to make to array1 in order to make it equal to array2.