answersLogoWhite

0

How do you you pass a parameter to setTimeout?

Updated: 8/20/2019
User Avatar

Wiki User

12y ago

Best Answer

You can pass a parameter in to setTimeout by using a closure instead of a direct function call.

var eggs = 0;

function addOneAndPrint (num)

{

num += 1;

console.log(num);

}

//Add one to eggs and print that to the console in a second

setTimeout(

function()

{

addOneAndPrint(eggs);

}

, 1000);

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you you pass a parameter to setTimeout?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is meant by the term SetTimeOut?

SetTimeOut is a term that is used in Java programming. It refers to the time it takes for a function in a program to time out or stop. SetTimeOut is a vital function.


Can you pass the object as parameter?

But of course.


How do you pass structures as a parameter to the functions in c plus plus?

Put their names into the parameter-list.


How do you pass the parameter in applet?

If you have the function main()... You can use its arguments to pass information.


One of strategy in programming a form of parameter transmission in which a copy of value of a parameter is sent to procedure...what is it?

pass by value


How to pass the parm parameter in PL1?

In JCL it would be of the form exec pgm=mypgroam, parms="/B" where the info after the "/" is the parameter strring.


What is the term used for the variable that receives an argument that pass into a module?

parameter


In what way is an argument passed by so it is not affected by a change of the content of the parameter value?

Pass by value.


Which is the default parameter passing technique in c plus plus language?

The default is to pass by value.


Is it possible in C plus plus builder xe to pass objects like TSQLConnection object to a dll as a parameter if yes then how?

Pass the object by reference to a function in the DLL.


What are the different parameter passing methods used by c plus plus?

Pass by value, constant value, reference and constant reference. Pass by value is the default in C++ (pass by reference is the default in Java).


Is A query that prompts for input whenever it is run is a run-time query?

It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.It is referred to as a parameter query.