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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:01:46+00:00 2026-05-15T13:01:46+00:00

I am having trouble understanding this code: $.functionone = function(){ function setOptions(newOptions){ … }

  • 0

I am having trouble understanding this code:

$.functionone = function(){
  function setOptions(newOptions){
      ...
  }
  this.setOptions = setOptions;
}

what does adding ‘this’ in ‘this.setOptions’ for? I understand that its referencing the function setOptions, but does adding the ‘this’ there make the function get called? I know this refers to the DOM element, but whats the point of having it in this particular scenario. Thanks.

  • 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-15T13:01:46+00:00Added an answer on May 15, 2026 at 1:01 pm

    That will simply expose the function from the scope of functionone, to be a property of the $ object.

    For example:

    $.functionone = function(){
    
      function setOptions(newOptions){
        //...
      }
      this.setOptions = setOptions;
    };
    
    typeof $.setOptions; // "undefined", it doesn't exist
    $.functionone();
    typeof $.setOptions; // "function"
    

    The this value on JavaScript is set implicitly when you make a function call.

    If the function is bound as a property of an object (like $.functionone), the this value will refer to the base object ($ in your example).

    That’s not so useful IMO, it’s equivalent to:

    $.functionone = function(){
      this.setOptions = function (newOptions) {
        //...
      };
    };
    

    Which is at the end, when you invoke functionone, equivalent to:

    $.setOptions = function (newOptions) {
      //..
    };
    

    The difference is that the function is not named, which can be useful for debugging.

    Working with the this value on jQuery plugins is more usual when you extend the jQuery.fn object, in that case the this value refers to the jQuery object that contains the matched elements, and not to the jQuery constructor itself.

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

Sidebar

Related Questions

I'm having trouble understanding the screen timeout function and how that will effect code
I'm having some trouble understanding this piece of code that my professor used as
So I'm having a bit of trouble understanding this example that was shown in
I am having a bit of trouble understanding this bug. Here is the code:
I'm having trouble understanding this bit of code in java.util.Arrays in openjdk. I'm curious
I am having trouble understanding this java code. I want the image to twinkle
I'm having trouble understanding how QGraphicsItemAnimation's setScaleAt function works. Here's the code I'm using:
I am having trouble understanding why my code is behaving as it does. What
I'm having trouble understanding the following bit of code that I was hoping would
I'm having some trouble understanding why this code won't work. I got it from

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.