How i can access the object data using variable value as key?
Let say i have this object:
let item = {
name: {
first_name: "Mark",
last_name: "James"
}
}
How i can get the value of first name using variable value?
I know i can access it using
item.name.first_name
What if i want to access it using variable value like this:
let key = "name.first_name"
console.log(item[key])