There is a function that returns a value for the key I specified.
function l(key){
let selectedLang = window.localStorage.getItem('language') || lang.default;
return lang[selectedLang][key];
}
const en = {
sidebar : {
"a" : "b",
}
}
l('sidebar') // function gives an object, its okay
But I want to use like this, how can I do that?
l('sidebar.a') // Now it's undefined
[]. To dive deeper into an object you need to concatinate multiple[]. So in your caselang['sidebar']['a']