This may be a dumb question, but why is the below for loop going into an endless loop in Chrome but not in Firefox? (Obviously, the loop test is where it's failing - I just don't know why).
for(var i = 0; localStorage[this.config.localStoragePrefix + i] != 'undefined'; i++)
It's doing checking how many localStorage elements exist. For example:
Would return 3.
Any thoughts on why this loops forever in Chrome?
This is because you are comparing it to the string representation of undefined, rather than undefined itself:
localStorage['asdf'] >>undefined localStorage['asdf'] == undefined >>true localStorage['asdf'] == 'undefined' >>false
So you have two options, you can
typeof localStorage['asdf'] != "undefined"
localStorage['asdf'] != undefined
localStorage[this.config.localStoragePrefix + i] != 'undefined' always returns true, as you're comparing to 'undefined' string. Change to to
undefined primitive or test using
it's because 'undefined' is different then undefined :P
for(var o in localStorage) if (localStorage[o]) this.config.appCount++;