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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:29:01+00:00 2026-06-02T10:29:01+00:00

Why does jslint complain about using this in a declared function? function navigate() {

  • 0

Why does jslint complain about using this in a declared function?

function navigate() {
    var id = $(this).attr('id');
}

Gives me:

#1 Strict violation.
var id = $(this).attr('id'), // Line 18, Pos 20

Yet jslint gives no complaint about:

var navigate = function () {
    var id = $(this).attr('id');
}

I’m using them both in the same way, and they both work correctly in the browser.

view.on('click', navigate);

FYI, I got around the warning by using event.target instead, but I would like to know what the distinction is.

function navigate(event) {
    var id = $(event.target).attr('id'); // no complaint
}
  • 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-06-02T10:29:02+00:00Added an answer on June 2, 2026 at 10:29 am

    Have a look at this link:
    https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/function-declarations.html

    From this excellent reference here:
    http://shichuan.github.com/javascript-patterns/

    These reasons are provided, but I’m not sure how convincing they are:

    1. Makes it easier to understand “functions as an object”.
    2. It enforces good semicolon habits.
    3. Doesn’t have much of the baggage traditionally associated with functions and scope.

    Reasons for “named function expression” on that page are a little more persuasive, but still not overwhelming.

    By the way, those appear to come from John Resig (of jQuery fame), as linked here:
    http://ejohn.org/blog/javascript-as-a-first-language/

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

Sidebar

Related Questions

Update: Turns out that this is a duplicate of: JSLint: Using a function before
Why does JSLint complain if something uses a function that hasn't been defined already?
Passing this code through jsHint: var A = function (spec) { use strict; var
What does JSLint mean by this error? And how should it be rewritten? Error:
Does the following function cause stack overthrow eventually? var isFinish= false; function foo(){ //
I've been using JSLint to make me feel bad about my JavaScript. It is
Does $this->db->insert_batch(); insert with 1 table connection or does it insert each row separately
Does any one know how I can have this happen in a windows phone
Does this below class is immutable? class Immutable { private int x; Immutable(int value)
I thougth bad escapement stands for wrong use escaping with slash. Why does JSLint

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.