Hey Folks,
Originally sent this yesterday but it never seemed to come through.
Apologies if you get it twice.
I'm working on some code for a catalog style application and I need to
compare objects from two different sets of data. Any object may have 10+
properties and I need to know if *some* properties have identical values. So
far I have been doing this the old fashioned way but I am wondering if there
is a much faster/better way to achieve the same result.
This is my present solution, would love to hear how clever people out there
handle this:
// param filterObj determines the props and values that must match e.g.
{prop1:"a", prop2:"b"}
function compareItems (filterObj:Object) : Array {
var resultArr = new Array();
var itemArr = RS.items;
for (var i = 0; i < itemArr.length; i++) {
var propMatch = true;
var tmpItem = itemArr[i];
for (var j in filterObj) {
if (tmpItem[j] != filterObj[j]) {
propMatch = false;
break;
}
}
if (propMatch) {
resultArr.push (tmpItem);
}
}
Thanks,
Clark
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders