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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:01:50+00:00 2026-05-16T15:01:50+00:00

Now, I usually call a function (that requires no arguments) with () like this:

  • 0

Now, I usually call a function (that requires no arguments) with () like this:

myFunction(); //there's empty parens

Except in jQuery calls where I can get away with:

$('#foo').bind('click', myFunction); //no parens

Fine. But recently I saw this comment here on SO:

“Consider using setTimeout(monitor, 100); instead of setTimeout('monitor()', 100);. Eval is evil :)”

Yikes! Are we really eval()-ing a string here? I guess I don’t really understand the significance and implications of ‘calling’ a function. What are the real rules about calling and referring to functions?

  • 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-16T15:01:50+00:00Added an answer on May 16, 2026 at 3:01 pm

    In JavaScript functions are first-class objects. That means you can pass functions around as parameters to a function, or treat them as variables in general.

    Let’s say we are talking about a function hello,

    function hello() {
        alert('yo');
    }
    

    When we simply write

    hello
    

    we are referring to the function which doesn’t execute it’s contents. But when we add the parens () after the function name,

    hello()
    

    then we are actually calling the function which will alert “yo” on the screen.

    The bind method in jQuery accepts the type of event (string) and a function as its arguments. In your example, you are passing the type – “click” and the actual function as an argument.

    Have you seen Inception? Consider this contrived example which might make things clearer. Since functions are first-class objects in JavaScript, we can pass and return a function from within a function. So let’s create a function that returns a function when invoked, and the returned function also returns another function when invoked.

    function reality() {
        return function() {
            return function() {
                alert('in a Limbo');
            }
        };
    }
    

    Here reality is a function, reality() is a function, and reality()() is a function as well. However reality()()() is not a function, but simply undefined as we are not returning a function (we aren’t returning anything) from the innermost function.

    So for the reality function example, you could have passed any of the following to jQuery’s bind.

    $('#foo').bind('click', reality);
    $('#foo').bind('click', reality());
    $('#foo').bind('click', reality()());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Almost every ios app now has something like Feed option. Programming that usually includes
Every now and then I need to call new[] for built-in types (usually char
I would like to call a java class from perl. I usually use the
I'm using a 3rd party library that passes function pointers to a method call.
When detecting eyes using HaarDetectObject() function, we get the results (detectedObjects) like this: [((110,
Is that possible to define a function without referencing to self this way? def
I usually call myControl.Focus() in the Loaded event handler, but this doesn't seem to
i usually develop for iPhone. But now trying to make a pong game in
Usually I worked with PostgreSQL and never had a problem, but now I need
Usually i write my where statements as WHERE key=@0 then add a param. Now

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.