var storage = chrome.storage.local;
storage.get("key1", function (items){
if(items.key1 != undefined) { // Or items["key1"] != undefined
storage.remove("key1", function (){
console.log("Key1 has been removed");
});
}
else {
storage.set({"key1":"value1"}, function (){
console.log("Key1 has been set");
});
}
});