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
  • 20,493
  • 5
  • 36
  • 47
Jason Bale
  • 333
  • 6
  • 13

0 Answers0