dynamic key name javascript object
here you can see the live demo and see code there alsolive demo url: http://jsbin.com/edibuk
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script>
var curdoctypedata = {};
var map = {
'key 1 from map': 'val1',
'key 2 from map': 'val2'
};
//assign dynamic key
$.each(map, function(key, value) {
curdoctypedata[key] = value ;
});
//display assigned dynamic key name
$.each(curdoctypedata, function(key, value) {
alert ('key: ' + key + '|||' + 'value: ' +value);
});
</script>
No comments:
Post a Comment