I'm following the chrome extension tutorial https://developer.chrome.com/docs/extensions/mv3/getstarted/ right now and part of their example code takes, in the parameter of the get() method's function parameter, a {color} object:
let changeColor = document.getElementById("changeColor");
chrome.storage.sync.get("color", ({ color }) => {
changeColor.style.backgroundColor = color;
});
From what I understand, this parameter represents an object that contains all the key-value pairs in storage. In storage, there exists one key-value pair, "color": "#3aa757" and was passed into storage using the line chrome.storage.sync.set({color}) where color had already been declared and assigned to "3aa757".
I am confused as to why the parameter here is typed as an object containing the variable name rather than just some arbitrary variable name like "data" or "result", as it is in the documentation:
chrome.storage.local.get(['key'], function(result) {
console.log('Value currently is ' + result.key);
});
How are these options different?