3
I would like to compare these two objects and return the index that is different.
In this case it is to return the 4 of the second object (will always be different in the second).
var arr = {
1 : 'Corsa',
2 : 'Ka',
3 : 'Pálio'
};
var foo = {
1 : 'Corsa',
2 : 'Ka',
3 : 'Pálio',
4 : 'Jeep'
};
How do I do this in Javascript or using jQuery ?
And if there’s more, if there’s 5 you want both (4 and 5) or only 5?
– Miguel
It will always be 1 different.
– Diego Souza
There’s only one, okay I get it
– Miguel
And the order will always be the same, equal values will always have the same index or if you have different order also return?
– Woss
In fact it will come in alphabetical order.
– Diego Souza
I removed the answer, because I can’t fix it now. But feel free to post something cooler. In principle the logic is the same, iterate one and see if you have it in the other, and accumulate the results when you don’t find it. @Moshmage grateful for the warning. Anderson, the doubt you put in the answer is pertinent.
– Bacco
@Bacco I understood its logic. Even why array is not so different from treating with respect to object.
– Diego Souza