Array vs Object

Is it a array or object ? I am confused.

Hey somen18,

It looks like it’s an object inside an array. Remember that an array uses square brackets [ and ]. Objects have key: value pairs.

How can I extract data from it ?

Actually, it’s object inside an array that’s inside an object. What exactly are you trying to extract?

Like gender,sport type etc.

It’s JSON data: JSON - JavaScript | MDN (mozilla.org)
Also: Working with JSON - Learn web development | MDN (mozilla.org)

Like people before me pointed out, its a JSON format, which is basically a string representing JS data(objects/arrays). It takes some particular methods to parse the data and be able to work with it. Once its parsed, you can use it as regular object/array notation. From the thumbnail, its one big object, which has a key named “teams” and that prop has an array value, which on its turn has an object as the first element with a range of keys. Accessing the parsed data, you could do something like- console.log(parsedData.teams[0].idTeam), which should return the value of 133604(this is the top inner value from the image).

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.