0

I have one object

my_object = {"first_name":"Harry", "age":"24", "second_name":"snow"};

I can get the first name value using

console.log(my_object.first_name); //Harry

and I am getting Harry . Here everything working fine . But for the below code I am not getting values

var num_1 = "first_name";

console.log(my_object.num_1); //undefined

console.log(my_object+"."+num_1);  //[object Object].first_name

Please help to solve this. Why I am not able to get object values using num_1 . I need to get the object values using num_1.

John
  • 97
  • 5

0 Answers0