var data = [{
"amount": "1",
"year": "2017",
"month": "March"
}, {
"amount": "1",
"year": "2017",
"month": "April"
}, {
"amount": "1",
"year": "2017",
"month": "May"
}];
$.each(JSON.parse(data), function(i, v) {
console.log(v.index())
console.log(v.amount)
console.log(v.year)
console.log(v.month)
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
How to get the index of an object that is inside an array using .each()
Currently I am using .index() but it is not working for me
each()method docs before posting here? In your question I already see you addi, vinside the function, which meansindexandvalue.iis the index you are looking for.