Iterating Array of Objects in javascript
javascript, jquery
Solution
Using `jQuery.each()`:
var array = [
{caste: "Banda", id: 4},
{caste: "Bestha", id: 6}
];
$.each(array, function( key, value ) {
console.log('caste: ' + value.caste + ' | id: ' +value.id);
}
);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Problem
I am having an array that consists the objects with a key, value how can we iterate each object for `caste` and `id`. ``` [ Object { caste = "Banda", id = 4 }, Object { caste = "Bestha", id = 6 } ] ```