You’re calling the function immediately and scheduling its return value.
Use:
setTimeout(testFunction, 2000);
^
Notice: no parens.
More Related Contents:
- Why the timer setTimeout returns the first value “2”
- setTimeout in a for loop with array as an argument misbehaving
- Chrome: timeouts/interval suspended in background tabs?
- Best way to iterate over an array without blocking the UI
- How to make a promise from setTimeout
- What is minimum millisecond value of setTimeout?
- Is there ever a good reason to pass a string to setTimeout?
- Why does setTimeout() “break” for large millisecond delay values?
- setTimeout ignores timeout? (Fires immediately) [duplicate]
- Why the function called by setTimeout has no callstack limit?
- What is setTimeout doing when set to 0 milliseconds?
- NodeJS Timeout a Promise if failed to complete in time
- setTimeout / clearTimeout problems
- setInterval in a React app
- Maximum call stack size exceeded on SetTimeout recursive function (Javascript) [duplicate]
- find the time left in a setTimeout()?
- How do I clear this setInterval inside a function?
- using setTimeout synchronously in JavaScript
- How to test a function which has a setTimeout with jasmine?
- Get return value from setTimeout [duplicate]
- Is setTimeout with no delay the same as executing the function instantly?
- Why does the Promise object block rendering?
- recursive function vs setInterval vs setTimeout javascript
- setTimeout not working inside forEach
- Global variable is logged as undefined when passed as parameter to setTimeout callback function
- how many javascript setTimeout/ setInterval call can be set simultaneously in one page?
- setTimeout Internet Explorer
- setTimeout() method inside a while loop [duplicate]
- setTimeout(): If not defined in EcmaScript spec, where can I learn how it works?
- Is it bad practice to pass a string to settimeout? If yes, why? [duplicate]