sse sse - 4 months ago 54
Javascript Question

Extracting data from JSON returned undefined

I'm new to javascript and JSON. I have JSON like this:

data = [[{"checked":false,"no":"1"},{"checked":true,"no":"2"}]]

But I am having a hard time looping through just to get the "checked" value.

I used for loop then i try to console.log data.checked but it always returned undefined. How can do this?


Get first array element using index and use Array#forEach method for iterating.

var data = [
    "checked": false,
    "no": "1"
  }, {
    "checked": true,
    "no": "2"

data[0].forEach(function(v) {