Syntax

JavaScript Run Code After a Delay Syntax

In JavaScript, run code after a delay: runs a function once after milliseconds — setTimeout(() => { ... }, 1000);

Quick Answer

Syntax
setTimeout(() => { ... }, 1000);
JavaScriptSyntax

Run Code After a Delay

Code example
setTimeout(() => { ... }, 1000);

Runs a function once after milliseconds.

Learn More

How to run code after a delay in JavaScript

  1. Open your JavaScript file or editor.
  2. Copy the example, then replace its sample names and values for your code.

JavaScript Run Code After a Delay Syntax

Use setTimeout(() => { ... }, 1000);.

Related Syntax References

Frequently asked questions

What is the JavaScript syntax for run code after a delay?

Use this pattern: setTimeout(() => { ... }, 1000);

Can I copy this JavaScript code example?

Yes. Use Copy code and adapt the example to your program.

Is this JavaScript syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify