I want to achieve the functionality of:
Iterate over the array in the object where k1's value is woo hoo!.
The following works but i'm not sure it's the best way because I think it would need to loop over each object before it found a match.
Array
myArray = [{"k1": "woo hoo!", "k2": ["k2_1","k2_2","k2_3"], "k3": ["k3_v1"]},{"k1": "boo", "k2": ["k2_v1"], "k3": ["k3_v1"]}]
jQuery
$.each(myArray, function (obj, v) {
$.each(v.k2, function (i, value) {
if (v.k1 == "woo hoo!") {
alert(value);
}
});
});
The following contains this example as well as a few other commented out examples I have used to understand $.each more.
console.log()- jsfiddle.net/arunpjohny/PPrxZ/1