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 6163261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:47:47+00:00 2026-05-23T21:47:47+00:00

I am currently running JSLint against the javascript in my web application and getting

  • 0

I am currently running JSLint against the javascript in my web application and getting some errors that I require assistance with resolving.

a. First error I am getting is: JS Lint: Unused Variable ‘n’.

 $.each(collection, function (n, item) {
                var temp = item.Id;
        // do further processing
    });

b. I have all my javascript declared in a self executing function like such:

(function ($, undefined) {
// further javascript code
}
(jQuery));

The above pattern can protect the $ from conflicting with other JavaScript libraries and also protect undefined from being redefined. However I get these errors from it:

JS Lint: Expected an identifier and instead saw ‘undefined’ (a reserved word).
JS Lint: Unused Variable ‘undefined’.

c. JS Lint: Unescaped ‘-‘.

 if (value.match(/^[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$/i)) {
    return true;
 }

d. JS Lint: Type confusion: ‘printer-‘: string and ‘(‘: number.

  var frameName = "printer-" + new Date().getTime();

I get numerous errors of Type confusion, sometimes with numbers, integers and other data types. Any idea as to how I can prevent getting these?

e. JS Lint: Insecure ‘^’.

var value = value.replace(/[^\d\.,\-]/gi, '');

f. JS Lint: Don’t make functions within a loop.

for (i = 0, l = txts.length; i < l; i += 1) {
        if (/^[0-9]+$/.test(txts[i].getAttribute("maxlength"))) {
            var func = function () {
                //do some processing
            };
        }
    }
  • 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-23T21:47:48+00:00Added an answer on May 23, 2026 at 9:47 pm

    A.) See: http://api.jquery.com/jQuery.each/

    you can use:

    $.each(collection, function() {
        doSomething(this); // this refers to the current iteration
    });
    

    B.) If you aren’t actually using “undefined” you aren’t protecting it from anything

    C.) I’m not going to bother with regex lol EDIT: Perhaps it wants [A-Z0-9\-]

    D.) You are concatenating string with number. Try 'string' + Date.getTime().toString() instead

    See also JSLint Type Confusion: function and object with jQuery .css() for type confusion stuff, there are some oddities that I don’t agree with

    E.) Again I’m not going to try for the regex EDIT: Here’s an identical question though: JSLint "insecure ^" in regular expression

    F.) If you can create your function once outside of the loop and then use it inside the loop (as long as you do it well) it is a significant performance increase.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently running Lucene.net in a web application and am wondering about the best
I have a currently running PHP application that I want to add real-time feed
We are currently running a Java integration application on a Linux box. First an
I'm currently running a web-app that will send emails to users when they sign-up,
I'm currently running an application that can only be run through a program/s commandline
I'm currently running my web application on Java1.5 codebase, running it on Tomcat 5.5
We are currently running a SQL Job that archives data daily at every 10PM.
We're currently running with php 5.2.5. We have now encountered a bug that creates
I'm currently running into some issues resizing images using GD. Everything works fine until
Currently running a live e-commerce site that uses Hibernate 3.1 and JBoss Treecache in

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.