Remedy for variable was used before it was defined from jslint
jslint requires a variable is declared with the keyword var before use it, including the global variables. Otherwise, you will get jslint error such as below
- ‘someVariable’ was used before it was defined
- ‘document’ was used before it was defined
- ‘window’ was used before it was defined
- ‘alert’ was used before it was defined
- ‘console’ was used before it was defined
- ‘require’ was used before it was defined
The remedy for this type of jslint errors is to put this line on top of the js file in a comment for native global variables.
/*global document, window, alert, console, require*/
For custom variable, you just have to declare it with the keyword var before use it.
Search within Codexpedia
Custom Search
Search the entire web
Custom Search
Related Posts