Листинг
function extraParser(extra) {
let output = {};
extra
.split('&')
.filter(e => !!e)
.forEach(e => {
const objWithKey = e.split('=');
const key = objWithKey[0];
output[key] = objWithKey[1];
});
return output;
}
Пример
extraParser('&yUnitSystem=binary&areaMode=stacked')
// => {yUnitSystem: 'binary', areaMode: 'stacked'}