Skip to content

Commit fd36122

Browse files
authored
Updated README.md
ADD - 335Q
1 parent 73e5b9d commit fd36122

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8743,10 +8743,11 @@ console.log(val.toString(16)); // A ==> Hexadecimal Conversion
87438743
<div align="right">
87448744
<b><a href="#">↥ back to top</a></b>
87458745
</div>
8746+
87468747
## 335Q. ***How setTimeout() and setInterval() are different from each other ?***
87478748
87488749
```javascript
8749-
#Syntax for setTimeout
8750+
//Syntax for setTimeout
87508751

87518752
function displayMessage() {
87528753
console.log('This message will be displayed only once after 4s!') ;
@@ -8757,7 +8758,7 @@ setTimeout(displayMessage, 4000);
87578758
```
87588759
87598760
```javascript
8760-
#Syntax for setInterval
8761+
//Syntax for setInterval
87618762

87628763
function displayMessage(){
87638764
console.log('This message will be displayed after every 4s!') ;
@@ -8767,18 +8768,18 @@ setInterval(displayMessage, 4000) ;
87678768

87688769
```
87698770
8770-
Usage : setTimeout(function/expression, timeout, param1, param2, ...) ;
8771+
Usage : setTimeout( function/expression, timeout, param1, param2, ... ) ;
87718772
8772-
where expression is the JavaScript code to run after the timeout milliseconds have elapsed. The params are optional.
8773+
where expression/function is the JavaScript code to run after the timeout milliseconds have elapsed. The params are optional.
87738774
87748775
Usage : setInterval ( function/expression, interval, param1, param2, ... );
87758776
87768777
where expression/function is the JavaScript code to run repeatedly at specified interval of time has elpased .
87778778
8778-
Main Difference
8779+
Main Difference
87798780
8780-
When you need to invoke a function once after a specified duration use setTimeout() function.
8781-
But, if you need to invoke a function repeatedly at a specified interval of time, then you should use setInterval() function.
8781+
When you need to invoke a function/expression once after a specified duration use setTimeout() function.
8782+
But, if you need to invoke a function/expression repeatedly at a specified interval of time, then you should use setInterval() function.
87828783
87838784
<div align="right">
87848785
<b><a href="#">↥ back to top</a></b>

0 commit comments

Comments
 (0)