I am using this piece of code inside a javascript function. But when I run the application it gives a reference error that local Storage is not defined.
localStorage.setItem(result.key+authAppParams.application , result.key);
Why this occurs? Why can't I use this inside a function? Since it is a setItem and all the releated values are inside the method I cannot define the local Storage globally.
How can I avoid this issue and make this work?
When using localStorage you should always check for it first to make sure the browser has it implemented.
Something like this
Should probably check for it early on in your code and only use it if it's available.
JS will always look on the global for a variable that it cannot find in the current context, so it looks as if it comes down to the browser not having it.
Edit Like everyone is commenting, localStorage and jQuery are completely separate