I have an object that's set like this:
var getObj;
getObj = JSON.parse(
typeof(Storage) !== 'undefined' ?
sge.getItem(saveName) : // sge and saveName are set earlier
getCookie(saveName) || false // getCookie is a separate function to read a cookie; if no cookie is found it returns ''
);
if (
Object.values(getObj).length > 0 &&
(getObj.timestamp + 60000) > Date.now() // expired
) {
sge.removeItem(saveName);
setCookie(saveName, '');
// does this empty the object?
getObj = {};
}
in the JSON.parse() section, if the type is not undefined then I set getObj to the results of .getitem(); if it's undefined then I try to set it to the results of getCookie(). But if there's no cookie... there's where I have the question.
I would THINK that I should set it to {}; eg, declare it as an empty object. Which is what I do in the next-to-last line, which I think empties the object.
But
getCookie(saveName) || {} throws an error that
object Object is not valid JSON.
If I should be setting it to false (like in the code above), then does that next-to-last line also need to be
getObj = false instead of
getObj = {}?