How to set variable key and value in Google Chrome local storage sync? [duplicate]
问题 This question already has answers here : How to use a variable for a key in a JavaScript object literal? (15 answers) Closed 3 years ago . I'm using Chrome's version of localStorage (chrome.storage.sync) and I want to use a variable key and value when setting what data to store with it. I'd like to be able to do something like this: chrome.storage.sync.set({ user: id }, callback); where the user and id are dynamically generated. This: var user = "Bob"; var id = "81256309"; chrome.storage.sync