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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:30:16+00:00 2026-05-15T10:30:16+00:00

I have run into this jquery plugin and i quite understand how this works:

  • 0

I have run into this jquery plugin and i quite understand how this works:

$.functionone = function(){

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

What i dont understand is what does this actually do? this.setOptions = setOptions can you call a function without parenthesis? What is the relationship between this.setOptions and setOptions by itself?

  • 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-15T10:30:17+00:00Added an answer on May 15, 2026 at 10:30 am

    Functions in JavaScript are objects like (nearly) everything else. When you do this:

    this.setOptions = setOptions;
    

    you’re not calling the setOptions function, you’re just assigning a reference to the function to a property, exactly like setting a property to any other object, like this:

    var dt;
    dt = new Date();
    this.today = dt;
    

    With functions, you’d do this so you can later call the function via the property (which sets up the this value to be the object the property’s on, which is handy). It’s a bit clearer what’s going on if you use a different name for the property than for the function:

    function functionName() { ... }   // Declares the function
    this.propertyName = functionName; // Sets the property
    functionName();                   // Calls the function (with `this` = the global object ["window", on browsers])
    this.propertyName();              // Also calls the function (but with `this` = the object the property's on)
    

    The pattern you identified, declaring a function and then separately setting a reference to it on an object, is frequently used to make sure the resulting function has a name. You can create a function and bind it to a property like this:

    this.setOptions = function() {
        ...
    };
    

    …but then the function doesn’t have a name (the property does, but not the function), which can be an issue when you’re trying to debug because debuggers show you the names of functions in various contexts (call stacks, for instance). If a lot of your functions don’t have names, even though the properties referring to them do, it makes debugging difficult. More about anonymous vs. named functions here. (There’s also a difference in terms of when the function is instantiated, but going into it here would just complicate things.)

    You’d think you could combine things, like this:

    this.setOptions = function setOptions() {  // <=== DON'T DO THIS
        ...
    };
    

    …but although that mostly works, it triggers a bug in Internet Explorer / JScript (it creates two different functions for that code, which is at best a memory waste and at worst a very subtle and time-wasting problem, as it was in this question).

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

Sidebar

Related Questions

Has anyone run into this problem... In my layout.phtml I have: <head> <?= $this->headTitle('Control
This is an odd thing I've just run into. I have a web application
I am trying to use the JQGrid plugin and have run into an issue
I have run into an issue with JQuery form submissions and have found no
I I hafe a function which uses the $.prompt Jquery (impromptu) pluggin. This works
I have used Fancybox on multiple occasions and never run into this problem. I
I'm pretty new to javascript and jquery, and have run into a problem that
I have run into a common, yet difficult problem. I do not use Photoshop
I have run into a bit of a tricky problem in some C++ code,
I have run into an issue with WPF and Commands that are bound to

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.