I am operating inside of a javascript for()
loop and need to produce the following dynamically:
devCssFiles[ '../'+thisTheme._name+'/assets/css/main.css' ] =
'child_themes/'+thisTheme._name+'/master.less';
the intended result is an associative array that can be declared iteratively inside of a parent object, e.g. (thisTheme._name
is declared in an external JSON file which is read when the code below is processed, this part is working fine)
var myConfigObj = {};
for ( var key in thisThemeMetaObj ) {
var devCssFiles = [],
devCssFiles[ '../'+thisTheme._name+'/assets/css/main.css' ] =
'child_themes/'+thisTheme._name+'/master.less';
myConfigObj[thisTheme._name] = devCssFiles;
}
I'm trying to give a complete explanation, but the problem is quite simple, I'm just declaring the named key of the associative array incorrectly at the line which reads devCssFiles[ '../'+thisTheme._name+'/assets/css/main.css' ] = 'child_themes/'+thisTheme._name+'/master.less';
Can someone show me the correct syntax here?
The intended output should be a JSON object like this:
myConfigObject: {
'../themeFoo/assets/css/main.css': [
'child_themes/themeFoo/master.less'
]
}