This content has been marked as final. Show 3 replies
If you look at the == operator, you will see this:
"Two such variables are equal if they refer to the same object, array, or
function. Two separate arrays are never considered equal, even if they have
the same number of elements."
So, you need to compare element by element...
>> var aTestA:Array = ;
var aTestB:Array = ;
If you do trace(aTestA == aTestB);
you will get true...
Adobe Community Expert
Thanks for the speedy response. I promise to look closer at the documentation first next time.
Of course before you do an element by element test, just test the lengths. If they are not the same then you know for sure that the test will fail and that they aren't equal. Only if they have the same length do you have any hope of them being equal.
Also of course, depending upon your needs, these two might be equal:
So don't forget to sort them if that is going to be important to you.
And finally if you do something like
remember that array1 will now be sorted too. So if you want to make a duplicate of an array use Array.slice();
And yes this is all in the help files! They are good and if you make good on your promise you will benefit a great deal! :)