-2

Probably very easy question, but I couldn't find solution. How to get data from this object? Object in console.log
That how it looks in consolo.log()

UPDATE:

Thank you for you answers. That what I used before and it worked, but when I try on this array it returns error.

console.log(array[1].data);

Output picture

UPDATE2:

So I tried to make it a text, but I couldn't.

    console.log(tempArray);
    console.log("String: " + tempArray.toString());
    console.log("Stringify: " + JSON.stringify(tempArray));

Here is output: Stringify attempt result

Maybe there is something wrong with how I create this array.

let tempArray = [];

And in the loop

tempArray.push({"id": id, "data": data.routes[0].geometry});

Thank you,
Dmitry

  • this is an array use something like `array[0].date` or loop to get all date values – Muhammad Usman May 23 '18 at 22:19
  • Thank you for your answer, sorry but I was suppose to clarify it in question. I tried it before and it didn't worked, that is why I asking this question. I edited question. – Dmitry Nagorny May 24 '18 at 17:01

1 Answers1

0

That's an array of objects, so you would get elements from it like so:

console.log(obj[i].data)

Where i is the element (numbered 0 through 2) that you want to access.

Defacto
  • 141
  • 7
  • Thank you for your answer, sorry but I was suppose to clarify it in question. I tried it before and it didn't worked, that is why I asking this question. I edited question. – Dmitry Nagorny May 24 '18 at 17:01
  • Please post the output of console.log(data) in text format so I can see exactly what the object looks like. – Defacto May 24 '18 at 18:53
  • Thank you again for your time. I updated my question to explain what I'm doing there. – Dmitry Nagorny May 24 '18 at 19:38