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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:44:55+00:00 2026-06-14T12:44:55+00:00

I am looking into how jQuery source code works, I understand the jQuery object

  • 0

I am looking into how jQuery source code works, I understand the jQuery object just forwards a call to jQuery.fn.init where jQuery.fn is just a reference to jQuery.prototype.

Then in the source code, there is this line:

// Give the init function the jQuery prototype for later instantiation
jQuery.fn.init.prototype = jQuery.fn;

There is a comment to explain what the code does but I still can’t understand it.

  1. Can someone explain what does this line of code means? what later instantiation is it talking about and why do we need to set init’s prototype to jquery’s prototpe?

  2. is there a reason (like avoiding conflicts or readability or whatever) that jQuery source code is using jQuery.fn instead of using jQuery.prototype directly?

  • 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-14T12:44:57+00:00Added an answer on June 14, 2026 at 12:44 pm

    (This response is written assuming you have some understanding of prototypal inheritance. If you don’t, you need to read an article about it to fully understand what’s going on. Try doing a Google search for “prototypal inheritance javascript”.)

    When a new jQuery object is created internally, it is created with new jQuery.fn.init(). init is a constructor, so setting the prototype property on this constructor allows newly created jQuery objects to inherit all the properties of this prototype (all the methods of jQuery.fn).

    If just new jQuery() was used, as you seem to suggest, the object would inherit from jQuery.prototype but the jQuery function would be executed, which as you know does a lot. The init constructor is used instead because it doesn’t come with the baggage of the jQuery function. Setting jQuery.prototype to the same as jQuery.fn.init.prototype just allows you to do jqueryobject instanceof jQuery, which is nice, so that’s the reason the jQuery object has a prototype.

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

Sidebar

Related Questions

I'm coming from a Prototype background and looking into JQuery. I'd like to know
I tested source code from this tutorial http://query7.com/php-jquery-todo-list-part-1 and just deploy their source taken
I have just started looking into jquerymobile, done simple samples using jquery.mobile-1.0a1 . I
I've only just started looking into jQuery mobile and was going through the Theme
I'm looking into the code of the jQuery ToolTip plugin(hereinafter Tooltip), and have a
I am looking into the jQuery UI Resizable method and I have to DIVs
I'm looking into using the jQuery UI autocomplete widget to implement user lookup by
I'm looking to find the Javascript Event I need to put into jQuery's .bind
I am looking into using http://www.asual.com/jquery/address/ , but I am wondering how it effects
I'm looking at jquery resize plugin and can't understand certain things about how it

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.