I am using javascript. I have a global variable like:
var contentlabel = {
'post':'Posted Blogpost',
'like':'Liked your Blogpost'
};
I want to access the value of contentlable.post dynamically in another function dynamically based on the value retrieved (like, post, ..) as below:
var CONTENT_TYPE=content[i].contentType;
alert(CONTENT_TYPE); //line 1 --> proper output
alert(contentlabel.CONTENT_TYPE); //line 2 --> undefined
alert(contentlable.post); //line 3 --> proper output
Where content is an array consisting of 'post' and 'like'. At line 1 I am getting proper output say: post or like In place of 'post' I want to display 'Posted a Blog', so I tried like contentlabel.CONTENT_TYPE, but its not replacing CONTENT_TYPE with either post or like.
Can anyone suggest a way to bind this dynamically.
jsFiddle: http://jsfiddle.net/HWRwt/