0

How can I get a value in my array object in javascript?

here is my var array:

[{"id":"1","name":"john jay","phone":"1234567890"}]

I tried to do:

console.log(array.name);

and I also tried:

console.log(array["name"]);

and I also tried:

console.log(array[0].name);

and also tried:

console.log(array[0]["name"]);

and i also tried:

var hi = JSON.parse(array);
console.log(hi.['name']);

all those gave me the error:

undefined

please help, thanks

Hassan Imam
  • 21,956
  • 5
  • 41
  • 51
Jason Bale
  • 363
  • 2
  • 7
  • 14

0 Answers0