I'm trying to decipher some code and I stumbled upon this:
var disabled = mswDisabledValue === 'true' ? true : false;
var serviceWorkers = JSON.parse("[{\"scope\":\"/\",\"serviceWorkerUrl\":\"/uxsw/scope/root.js\"},{\"scope\":\"/x\",\"serviceWorkerUrl\":\"/uxsw/scope/now_x.js\"},{\"scope\":\"/now\",\"serviceWorkerUrl\":\"/uxsw/scope/now_x.js\"}]");
var SERVICE_WORKER_MANAGER_CONFIG = { disabled, serviceWorkers };
What does the third line mean?
I tried printing SERVICE_WORKER_MANAGER_CONFIG
, and it returned an object:
{
disabled: false,
serviceWorkers: [{
scope: '/',
serviceWorkerUrl: '/uxsw/scope/root.js'
},
{
scope: '/x',
serviceWorkerUrl: '/uxsw/scope/now_x.js'
},
{
scope: '/now',
serviceWorkerUrl: '/uxsw/scope/now_x.js'
}
]
}
Seems like I can declare an object using variables instead of key/value pairs, but I haven't found this documented anywhere. Is this the correct usage of JavaScript?