I have an angular problem
I have my object
user = {name: 'Alexandre', email: '[email protected]'}
I need a way to show on the console
var attr = 'name';
var attr2 = 'email';
insira o código aqui
console.log(user.attr) e me retorne Alexandre;
console.log(user.attr2) e me retorne '[email protected];
The second parameter of the object would be dynamically variable, how can I execute it?
I've tried it like this and nothing is right
user.attr;
user.{attr};
user.(attr);