I get the following error in jsLint:
'document' was used before it was defined.
Line that causes the error:
document.cookie = name + "=" + value + expires + "; path=/";
I get why this happens, but I would like my code to be compliant.
How do I resolve this?
Thanks.
Place
/*jslint browser:true */
in the beginning of the body of your function. Or, alternatively, you may use
/*global document: false */
JSLint is for the checking of any javascript code, and the document
global object does not exists everywhere, so you have to manually tell JSLint that your code is aimed to be executed in browser, and thus document
global variable is defined. For example, for server-side javascript it is expected for JSLint to report about this error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With