You need a bunch of loops, but you can optimize them and completely avoid nested loops with a search object.
var oldValues : Array = [ 4, 5, 6 ]; var newValues : Array = [ 3, 4, 6, 7 ]; var oldNotInNew:Array = new Array(); var newNotInOld:Array = new Array(); var oldLookup:Object = new Object(); var i:int; for each(i in oldValues) { oldLookup[i] = true; } for each(i in newValues) { if (oldLookup[i]) { delete oldLookup[i]; } else { newNotInOld.push(i); } } for(var k:String in oldLookup) { oldNotInNew.push(parseInt(k)); } trace("Old not in new: " + oldNotInNew); trace("new not in old: " + newNotInOld);
Results:
Old is not new: 5
new not old: 3.7
source share