For example, I have the object names:
let names = {
name: 'Jhon',
lastName: 'Doe'
}
Now, what I want to do is to search a key of the names object using a variable. For example I have the variable:
let variable = 'lastName';
What I want to do is to search the object key value like this:
console.log(names.variable)
And it should print Doe. How can I do that?