1

i am trying to get the object value with dynamic key. I have data array with keys that is:

Array[15]
 0:Object
   applied:43
   institute: ACET
   selected:  12
   year: 2013
 1:Object
   applied: 50
   institute: PTU
   selected:  10
   year: 2015
 .......

now from this data i just want to get all institute names and i am using jquery map function get the data:

var newData = vm.chart_data.map(function(obj) { return obj.institute; });
        console.log(newData);

if i am giving return obj.institute manually its working fine, but when i have to get the multiple keys value or when i am using in loop then i can't get the value from that object array:

var values = ['institute','year'];
var newData = vm.chart_data.map(function(obj) { return obj.values[0]; });
        console.log(newData);

is there any way to get that values?

Mihai Alexandru-Ionut
  • 47,092
  • 13
  • 101
  • 128
Rahul Sharma
  • 406
  • 3
  • 5
  • 17

0 Answers0