var custom = { key: { label: test } };
custom[type].label
var custom = { custom[type]: { label: test } };
var custom = { key: { label: "test" } }; var type = 33; function getVal(val) { for(var name in window) { if(window[name]==val) { return name; } } } custom = JSON.parse('{"' + getVal(type) + '":' + JSON.stringify(custom.key) + '}'); alert(JSON.stringify(custom));
var type = value1
var custom = {}; var type = 'value1'; custom[type]={ label: 'test' } alert(JSON.stringify(custom));
var custom = {...};
var custom = {}; var type = 'type'; custom[type]={ label: 'test' } alert(JSON.stringify(custom));