Метод, для работы с данными:
storage(action: string, name: string, data?: any):any {
if (typeof action !== "string" && typeof name !== "string")
return global.setError(`Check your types of arguments`);
const store = {};
switch(action) {
case "set":
store[name] = data;
break;
case "get":
return store[name];
case "del":
delete store[name];
break;
default:
return store;
}
}
Вызываю:
storage("set", "userData", {name: 'Name', email: 'email@gmail.com'});
console.log(storage("get", "userData")); // undefined
Почему
storage("get", "userData"));
возвращает
undefined
?