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

  • Home
  • SEARCH
  • 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 412099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:03:07+00:00 2026-05-12T18:03:07+00:00

Today, my only pressing question about jQuery is about the when to use jQuery.extend()

  • 0

Today, my only pressing question about jQuery is about the when to use jQuery.extend() and, jQuery.fn (which is used for plug-ins). Basil Goldman seems to have an explanation in “Defining your own functions in jQuery” but for some reason I’m still not satisfied that I have the best information. Once we start to work with jQuery.fn we must consider whether we should just build a full-blown plug-in. This implies three issues: extending, adding a new function and building a plug-in. There should be an explanation that coheres all three. Is this worthy of an explanation and do we have one?

  • 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-12T18:03:07+00:00Added an answer on May 12, 2026 at 6:03 pm

    I think you might be thinking too hard. 🙂

    In the jQuery source – extend() is defined once and used in both namespaces:

    jQuery.extend = jQuery.fn.extend =  function() { .. };
    

    Technically, all this function does is merge together object properties.

    So in the most basic use case, you just merge two objects into a single object (much like options parameters in plugins):

    this.options = $.extend({}, defaultOptions, userOptions); // Just mergin' objects
    

    The extend function on the plain-jane $||jQuery namespace merely adds that function as a static-like function in the jquery namespace. Functions that go on the jQuery namespace are generally ones that don’t require an element to operate on. These are functions like isArray() and isFunction() along with a bunch more.

    var noWhiteSpace = $.trim(string); // No element needed
    

    jQuery.fn is more or less reserved for functions that perform actions based on the elements that are passed into the jquery object. These are like normal plugins, and most of the things you’re used to in jQuery.

    $('div').css('border', '1px solid green'); // Do work on a set of elements
    

    More interestingly, if you look at something like the $.data() function in the jQuery source. It is defined in both namespaces. It is first defined in the $ namespace and takes and element as the first parameter. It is later extended onto $.fn and simply calls the first function with the first parameter set as ‘this.’

    Hope that’s what you’re looking for!

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

Sidebar

Related Questions

Today I stumbled about a Problem which seems to be a bug in the
Today I was listening to the Hanselminutes show about .NET 3.5 SP1...What's inside ,
Today I had a coworker suggest I refactor my code to use a label
Today when I was in computer organization class, teacher talked about something interesting to
Today I had a discussion with a colleague about nested functions in Javascript: function
Today only I have noticed and found out the importance of using === operator.
It's only started doing this today, so I assumed it was something I've done,
Today I implemented a small piece of code that include analytics only in production
I'm trying to enforce choosing only dates between (today minus a week, today plus
Today at work I had a discussion with my co-workers and my boss about

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.