JSLint (Javascript Validator Website) - Error! Implied Global:

I just tested my own gallery of script in JSLint .. and all the errors that were resolved except for one. Implicit global error .. Is it really a mistake? Can I ignore it or should I work on this to solve this error.?

Thank you for your responses!

alt text

Error: Implied global: <bunch of vars and other stuff i dont know> 

What does it mean? BTW I am using jQuery Library .. maybe this is a problem ^^ ..

+4
source share
3 answers

if you use external declared variables, for example, in this case, put the "global" operator at the top of your file, for example:

/ * global $, document * /

+6
source

The JSLint documentation states:

Undefined Variables and Functions

JavaScript's biggest problem is dependency on global variables, especially the implied global variables. If a variable is not explicitly declared declared (usually with var), then JavaScript assumes that the variable was global. This may be mask names with errors and other problems.

JSLint expects all variables and functions to be declared before they are used or called. This allows the discovery of implied global variables. this is also good practice as it makes programs easier to read.

Fix this error. Almost every coding convention requires that you not use implied global variables.

Variables can be declared using the var keyword.

+2
source

When writing JavaScript code for the browser, it is useful to tell JSLint that you are in browser mode, for example by enabling this:

 /*jslint browser: true */ 

This should allow "document", "setTimeout" and other standard browser settings.

Since jQuery is probably not evaluated in the same context as your JavaScript, you need to report that the always useful "$" is available with

 /*global $ */ 
+1
source

Source: https://habr.com/ru/post/1334654/


All Articles