I am trying to find the property value of an object based on key. I have below function getData
which returns the data based on key
passed as input parameter.
const getData = (key) => {
let row = {isSelected: true, Data: {Id: '1A', Value: 'LD'}};
return row[key];
}
console.log(getData('Data'));
In normal scenario it is working fine but how can I get the property value from nested object Data.Value
.
If I call getData function as getData('Data.Value')
, It should return LD
.