Below are two objects:
let x = {y: 'z'}
and let a = {z: 'b'}
I want to access a.{property}, where property is the the value of x.y
Please guide me.
Below are two objects:
let x = {y: 'z'}
and let a = {z: 'b'}
I want to access a.{property}, where property is the the value of x.y
Please guide me.
Use bracket notation if you want to use property dynamically
Use a[x.y]
. Please find example below:
let x = {y: 'z'};
let a = {z: 'b'};
console.log(x.y)
console.log(a[x.y]); // Final result
Please use this link to study about accessing object properties