Why is it that Internet Explorer does not recognize a string variable as a parameter for the setItem method, even though it works fine in Chrome?
For example, in IE:
This code snippet works:
var itemName = 'anyname';
localStorage.setItem(itemName, 'anything');
But this one does not work:
var itemName = 'anyname';
var stringName = 'some string content';
localStorage.setItem(itemName, stringName);
Instead, an 'Invalid argument error' is thrown. Any insight on how to resolve this issue would be greatly appreciated! :)
EDIT. The previous post mentioned another problem, but the example provided actually works for me! My issue lies in the fact that the setItem method does not accept a string variable as expected, unlike a regular quoted string. The solution suggested in the related post is not viable for my situation, as I cannot rely on end users installing an IE11 bug-fix.