
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
What is the difference between setTimeout() and setInterval() in JavaScript?
setTimeout( function, duration) − This function calls function after duration milliseconds from now. This goes for one execution. Let’s see an example −
It waits for 2000 milliseconds, and then runs the callback function alert(‘Hello’) −
setTimeout(function() { alert('Hello');}, 2000);
setInterval(function, duration) − This function calls function after every duration milliseconds. This goes for unlimited times. Let’s see an example −
It triggers the alert(‘Hello’) after every 2000 milliseconds, not only once.
setInterval(function() { alert('Hello');}, 2000);
- Related Articles
- What is setTimeout() Method in javascript?
- What is setInterval() method in JavaScript?
- What is the difference between == and === in JavaScript?
- What is the difference between comments /*...*/ and /**...*/ in JavaScript?
- What is the difference between jQuery and JavaScript?
- What is the difference between Java and JavaScript?
- What is the difference between JavaScript and ECMAScript?
- What is the difference between JavaScript and C++?
- What is the difference between functions and methods in JavaScript?
- What is the difference between null and undefined in JavaScript?
- What is the difference between Bower and npm in JavaScript?
- What is the difference between call and apply in JavaScript?
- What is the difference between window.onload and document.onload in Javascript?
- What is the difference between substr() and substring() in JavaScript?
- What is the difference between getter and setter in JavaScript?

Advertisements