0

Is it bug or my fault? Variable from string and from localStorage behave differently.

var colors ="", colors2 ="", getColor = "";

var defaultColorScheme = '{"asideBackgroud":"#fff", "asideColor":"#000", "sectionBackgroud":"#eee", "sectionColor":"#111"}';
if (!localStorage.colorScheme) {
    localStorage.setItem('colorScheme', JSON.stringify(defaultColorScheme));
} 
getColor = localStorage.getItem('colorScheme');
colors = JSON.parse(getColor); // from loc. storage
colors2 = JSON.parse(defaultColorScheme);   // string
alert (colors.asideBackgroud+" -- "+ colors2.asideBackgroud);
if (defaultColorScheme === colors) {
  alert("yes");
}

//localStorage.clear();

0 Answers0