1var someObj = { foo: "bar"};
2
3$.each(someObj, function(propName, propVal) {
4 console.log(propName, propVal);
5});
6
1var agents = [
2 {
3 "id": "007",
4 "agent": "James Bond"
5 },
6 {
7 "id": "006",
8 "agent": "John Wick"
9 }
10 ]
11// iterate over the JSON array
12$.each(agents , function(index, item) {
13 console.log("Agent Id: " + item.id);
14 console.log("Agent Name: " + item.agent);
15});
1$.map(mapArray, function(val, key) {
2 alert("Value is :" + val);
3 alert("key is :" + key);
4});