Can this be done? Take a look at a practical example from the real world:
var userKey = "userIdKey";
chrome.storage.sync.set({ userKey: "Hello World" }, function () {
chrome.storage.sync.get(userKey, function (data) {
console.log("In sync:", data);
});
console.log("Success");
});
This specific example is failing because the getter is expecting "userIdKey" while the setter is treating the variable as "userKey" literally.
UPDATE: I understand that variables can be accessed using array notation. The example I provided demonstrates the creation of an object. My goal is to ensure consistency in using the same key for both getting and setting values, rather than depending on keeping two string constants in sync.