I have a javascript object defined below:
var user = { name:'Allen', age:'26', gender:'male'}
I want to reference the user property user.name via string such as below:
var string = "name";
var username = user.string;
This doesn't work, how would I go about this?
EDIT: just to clarify, I want user.string to be the equivalent of user.name - some might ask why I don't just call user.name, and this is because I have an array of strings that I would like to evaluate for the object.