Using a variable key in chrome.storage.local.set [duplicate]
This question already has an answer here: chrome.storage.local.set using a variable key name 2 answers I am creating a chrome-extension. I don't know how to use a variable as the key to chrome.storage.local.set() function. I have tried var key = 'myKey'; chrome.storage.local.get(key, function(val) { chrome.storage.local.set({key:val[key]+param1}); //appending param1 alert(val[key]); } Here i am trying to get the value of val[key] and append a string param1 and place it back to the storage using the same key. But I am not able to do so. the alert box displays undefined all the time. But when I