I have the folowing code:
var windowNow = window.localStorage.getItem("windowNow");
switch(windowNow)
{
case 1:
var link = "http://www.zive.sk/rss/sc-47/default.aspx";
var listviewID = "feedZive";
break;
case 2:
var link = "http://mobilmania.azet.sk/rss/sc-47/default.aspx";
var listviewID = "feedMobil";
break;
case 3:
var link = "http://www.automoto.sk/rss";
var listviewID = "feedAuto";
break;
}
and I know that windowNow === 1 because I have checked it with alert and also to be sure that it realy is 1 I checked it with if(windowNow == 1) { alert ("Window now is 1");} and it worked. But it is not working inside my switch (checked it with alerts).
The items in the
localStorageare always strings. Usecase "1"and so on.The problem with your check is that is a loose check, which doesn’t check for the data type. You should have tried
Notice the triple
=.