how to access object property using variable [duplicate]

Solution 1:

Square brackets:

message = Messages[ attribute ];

Solution 2:

var message = Messages[attribute];