Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1113641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:53:18+00:00 2026-05-17T02:53:18+00:00

Lately I’ve been writing some JS code using jQuery and JavaScript as it is

  • 0

Lately I’ve been writing some JS code using jQuery and JavaScript as it is and I thought I will give JSLint a try. Let me say that the code contains various functions and jQuery usages and it works fine (without any errors ) in IE8 and latest Firefox.
The code also validatas as XHTML 1.0 Transitional (and Strict too but I mostly want it to be Transitional valid).

However, with JSLint it’s like everything is wrong. While I have read about it being very strict, even if I turn on only “The Good Parts” it’s still like 70+ errors in a typical HTML page.

It starts out with this (why in the world would I want to remove the type to make my documents XHTML invalid??)

Problem at line 5 character 67: type is unnecessary.

<script src="/Scripts/jquery-1.4.2.min.js" type="text/javascript"></script>

and goes on with esoteric errors like

Problem at line 41 character 41: Use the array literal notation [].

var rows = new Array();

Problem at line 42 character 30: Too many var statements.

for (var i = 0; i < data.length; i++) {

Problem at line 42 character 55: Unexpected use of '++'.

for (var i = 0; i < data.length; i++) {

Problem at line 64 character 50: ['PrettyId'] is better written in dot notation.

var item = $("#item_" + data["PrettyId"]);

If anyone can provide me answers to these errors and especially, how to make JSLint be aware of jQuery and understand it, I will appreciate it.

If not, please explain whether you use it or not and whether you advice to use it or not.

UPDATE:

I’m going to wait one more day for more answers, if any, then I’ll accept the answer with the most upvotes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:53:18+00:00Added an answer on May 17, 2026 at 2:53 am

    A thing to remember when using JSLint is that is built on the opinion about what one person thinks is the “Good Parts”.

    I think is a great tool but there are rules that I don’t agree with.

    About the type attribute, you can find more about the opinion of the author here he says that the attribute is “required and non necessary”, but if you validate your documents you clearly need it.

    With the use of the Array literal notation [] vs. the Array constructor, I agree, there are differences that can make the two syntaxes behave different, for example:

     [5]; // one-element array
     ["5"]; // one-element array
    
     new Array(5); // empty array but its length is initialized with 5
     new Array("5"); // one-element array
    

    So, for consistency an brevity the literal notation is better.

    About the “Too many var statements”, JavaScript has no block-scope, the scope is at function or global level, and all var statements are evaluated before the code execution -aka hoisting- and they are initialized with undefined, while the assignments are made at runtime.

    For example:

    var x = 0;
    if (true) {
      var x = 1; // useless var, x already declared
    }
    x; // 1
    

    And the “hoisting” of variable declaration can be shown in this example:

    var x = 5;  // global
    (function () {
      alert(x); // alerts `undefined`, x declared but unassigned in this scope
      alert(y); // ReferenceError, y is undeclared
    
      var x = 10;
    })();
    

    As you can see x holds undefined because it is declared before the actual code execution, the var statements are hoisted to the top of their enclosing scope:

    var x = 5;  // global
    (function () {
      var x;
      alert(x); // alerts `undefined`, x declared but unassigned
      alert(y); // ReferenceError, y is undeclared
    
      x = 10; // assignment is made
    })();
    

    So that rule wants to actually make the code to resemble what will happen, all the var statements at first place.

    About the “Unexpected use of ‘++'”, this is another rule that I don’t quite like, the author thinks that “those contribute to bad code by encouraging excessive trickiness”.

    When I use them in some expression, I try to extract the operator usage to an alone statement, for example:

    array[++id] = x;
    

    To:

    id+=1;
    array[id] = x;
    

    Which is more clearer, but anyway in the case of a for statement IMO it can’t cause any confusion at all…

    About the last one “[‘PrettyId’] is better written in dot notation.”, JSLint expects the usage of the bracket notation to be “dynamic”, it expects to see an expression there, not a String literal that contains a valid identifier name, the bracket notation should be used only when you want to access a property with a name that clashes with a reserved word e.g.:

    data.function;    // SyntaxError in ECMAScript 3 based implementations
    data["function"]; // Ok
    

    Or when a property contains characters that are not a valid identifier, e.g.:

    data.foo-bar;    // it access the property `foo` minus a `bar` variable
    data["foo-bar"]; // Ok
    
    data.foo bar;    // SyntaxError, unexpected `bar` identifier
    data["foo bar"]; // Ok
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lately, I've been reading some code that has if (! (a == b) )
Lately I've been using some pattern quite a lot but I don't know if
Lately I've been favoring using named pipes (option --enable-named-pipes) in MySQL running on windows,
Lately I have been playing around with intents and bundles. I thought I had
Lately, I've gotten some weird linker errors. I've been taught that there's two ways
Lately I've been running into some subtle layout issues in my iOS app. For
Lately I've been thinking about writing my own language - something I've wanted to
lately I have been writing a lot of tiny plugins for my web projects
Lately I have been finding that some of the ColdFusion applications on my production
Lately I have been doing some numerical method programming in C. For the bug

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.