最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jslint.com | Does not recognize localStorage - Stack Overflow

programmeradmin3浏览0评论

Getting error:

'localStorage' was used before it was defined.

What do I need to do to fix this?

localStorage is available on all modern browsers and as far as I know does not need to be defined.

Getting error:

'localStorage' was used before it was defined.

What do I need to do to fix this?

localStorage is available on all modern browsers and as far as I know does not need to be defined.

Share Improve this question asked Aug 15, 2012 at 23:08 user656925user656925
Add a ment  | 

2 Answers 2

Reset to default 15

Any global that you want to appear as defined to jslint can be defined in a ment of globals. E.g.:

/*global localStorage: false, console: false, $: false */

This would make localStorage, console, and $ (jQuery) not trigger that warning.

It doesn't know how the code will be used. You need to set the browser option. Note this is default in jshint. but not jslint.

发布评论

评论列表(0)

  1. 暂无评论