How can I pass a parameter to a setTimeout() callback?

To pass a parameter to setTimeout() callback, use the following syntax ?

setTimeout(functionname, milliseconds, arg1, arg2, arg3...)

The following are the parameters ?

  • function name ? The function name for the function to be executed.
  • milliseconds ? The number of milliseconds.
  • arg1, arg2, arg3 ? These are the arguments passed to the function.

Example

You can try to run the following code to pass a parameter to a setTimeout() callback


   
      
      
   

Click the above button and wait for 5 seconds.

   
Updated on: 2026-03-11T23:14:17+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements