What the question says…
Does jQuery have any methods that will allow you to query a mult-dimensional array of objects in a similar fashion as it does with the DOM.
So for instance, get me a list of objects contained within a multi-dimensional array having some matching property value – for instance where StartOfPeriod greater than a specified date or where name == “Ben Alabaster”
I’d like to avoid re-inventing the wheel if there’s something already out there.
You can’t use selector syntax, but jQuery comes with $.grep and $.inArray, which can be useful for this.
grepreturns a new array of elements that match a predicate.inArrayreturns the index of the first matching element, or -1. For instance:These are similar to the standard ECMAScript methods,
Array.filter(simimlar togrep) andArray.indexOf(similar toinArray); jQuery actually usesArray.indexOfwhere available. There are also other useful ECMAScript methods, such asArray.every(all elements matching) andArray.some(at least one matching). MDC has code you can add to your project so these work in browsers that don’t have native implementations.