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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:17:15+00:00 2026-06-04T02:17:15+00:00

So in previous questions I’ve been told to call/execute/start functions like thisFunc; instead of

  • 0

So in previous questions I’ve been told to call/execute/start functions like thisFunc; instead of thisFunc();.

And I’ve found that sometimes that works and sometimes it doesn’t.

<script type='text/javascript'>
var valgo = 0;
var thing = "";
var lastPost = document.getElementById(<? echo $_SESSION['countything']; ?>); 
lastPost.style.opacity = valgo;

function valgogoer(thing){
valgo += .05;
if (lastPost.style.opacity < 1){
lastPost.style.opacity = valgo;
}
}


setInterval(function(){valgogoer(<? echo $_SESSION['countything']; ?>)}, 50);

// Somethings are leftover from when I was messing with it, like the parameter thing.
</script>

In this code (and please tell me if it’s awful), because I’m using setInterval to call a function with a parameter, I found through research it must be called the way it is above.

So two questions

  1. When am I actually supposed to use () in calling functions?

  2. In the code above, how can I make it so that it stops executing that function after the opacity hits 1. Currently it’s restrained to 1, but it’s still being called, and I’ve got a feeling it’s better to stop the function being called, than to have it being called but not doing anything.

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-06-04T02:17:17+00:00Added an answer on June 4, 2026 at 2:17 am

    You use the brackets when you want to call the function. But if just wanna pass the content of the function, you do not. Examples:

    var a = function(){
        return "I'm a function";
    }
    var b = a;//Equals to function(){return "I'm a function";}
    var c = a();//Equals to "I'm a function"
    

    In event handlers, you do not use the brackets because you have to say to the browser to execute the content of the function. If you put them, the browser will call the return value of the function, which may cause an error:

    var a = function(){
        alert("Welcome to my site");
    }
    window.onload = a();//Wrong, equals to undefined, since the a function doesn't return any value
    window.onload = a;//Correct, calls the function a when the event is fired
    

    This same thing happens when you call the setInterval method with a function as the parameter. That’s why the brackets are so important

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

Sidebar

Related Questions

In one of my previous questions I explained about a form class that contain
After reading previous questions about this error, it seems like all of them conclude
The previous questions on SO that I came across are nearly 2 years old.
The topic has already been on the table in some previous questions. New elements
This is a question that builds off of one of my previous questions .
there has been many previous questions about redirecting stdout/stderr to a file. is there
I found some previous questions related to this, but I'm still unable to solve
actually I've read some previous questions about this... this is the code that I
and sorry should the question be redundant, but I've been looking through previous questions
If you check my previous questions, you will see that they are all in

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.