You do not need to use an anonymous function with setTimeout
. You can do something like this:
setTimeout(doSomething, 3000);
function doSomething() {
//do whatever you want here
}
More Related Contents:
- JavaScript sleep/wait before continuing [duplicate]
- Javascript function not working, what is wrong? [closed]
- How would I make a Timer which times things in 0.75 seconds Javascript?
- How to use variable instead of function name in JavaScript
- What is the difference between a function call and function reference?
- JavaScript variable number of arguments to function
- Is there a better way to do optional function parameters in JavaScript? [duplicate]
- How can I create an Asynchronous function in Javascript?
- Function in JavaScript that can be called only once
- How does this object method definition work without the “function” keyword?
- Dynamic function name in javascript?
- Adding custom properties to a function
- Proper use of const for defining functions
- Can any desktop browsers detect when the computer resumes from sleep?
- Javascript Image Url Verify
- Why doesn’t console.log work when passed as a parameter to forEach?
- Strange JavaScript idiom – what does “/xyz/.test(function(){xyz;})” do?
- functions inside or outside jquery document ready
- Where can I find javascript native functions source code? [duplicate]
- javascript named function expressions – scope accessibility [duplicate]
- js function to get filename from url
- Add a delay after executing each iteration with forEach loop
- List of global user defined functions in JavaScript?
- Javascript function challenge add(1,2) and add(1)(2) both should return 3
- How to create a sleep/delay in nodejs that is Blocking?
- Javascript: Get access to local variable or variable in closure by its name [duplicate]
- Lambda function syntax in JavaScript without curly braces
- What are the different ways of writing an IIFE? What are their use cases?
- How to get function body text in JavaScript? [duplicate]
- Why can’t I use a Javascript function before its definition inside a try block?