I've looked at several questions asking how to remember the variable, but I'm having the opposite problem which is surprising to me.
My main.js file will have this:
console.log(name);
and I get nothing. If I try to log it in the console it returns undefined, that is expected,
now I create the variable like this:
var name = "Sandy"; //global variable
console.log(name); //returns "Sandy" which is also expected.
But now the unexpected happens. I remove the variable so we're back to this, and then I refresh the page:
console.log(name); //This returns "Sandy" still...
How is this happening and why? I thought it was cookies, so I tried it in incognito mode (Maybe I misunderstand incognito?) But it works exactly the same.
In order to make the variable go away I have to close down the browser and open up a new window.
After reading briefly about LocalStorage, cookies, and incognito, it sounds like cookies are the problem, but wouldn't I have to create the cookie manually?
It seems like the browsers should be forgetting the variables unless I explicitly set the variable to a cookie.