Computer Science, asked by SoTy2884, 11 months ago

How to delay a JavaScript function call using JavaScript?

Answers

Answered by hassan911ee
2

Answer -

Hi. In order to delay a function, you can use the JavaScript method known as "setTimeout()"

This method accepts 2 parameters, ie, a function and the time in Milliseconds, which is basically an integer.

In order to delay your function just use -

setTimeout(yourFunction, time);

Example -

Suppose you have a function named myFunction -

function myFunction()

{

return 1+1;

}

In order to delay the function -

setTimeout(myFunction, 3000 );   // delaying the function by 3 seconds.

Answered by krrew
0

Answer:

Hi. In order to delay a function, you can use the JavaScript method known as "setTimeout()"

This method accepts 2 parameters, ie, a function and the time in Milliseconds, which is basically an integer.

In order to delay your function just use -

setTimeout(yourFunction, time);

Example -

Suppose you have a function named myFunction -

function myFunction()

{

return 1+1;

}

In order to delay the function -

setTimeout(myFunction, 3000 );   // delaying the function by 3 seconds.

Similar questions