Settimeout and setinterval in javascript

technical talkiess
0

 


Settimeout and setinterval 👍


<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Setineterval and clearinterval </title>

</head>

<body>

    <div class="container">

        Time is: <span id="time"></span>

    </div>

    <script>

        // aap aise bhi likh sakte hai  .... ye bar bar run karta hai

        timeout = setInterval(() => {

            // console.log("Test")

        }, 1000);


        // aap isme function bhi call kar sakte hai .... 3third parameter me aap parameter pass kar sakte ho.... jo function ko chaiye hai


        // timeout1 = setInterval(Greet, 1000,"vishal"," Take care");

        // clear interval function timeout 1 me serinterval ki jo id milti hai usko clear kar deta hai taki wo execute hi na ho


        // clearInterval(timeout1);

       

       

        // settimeout ..... funtion set the time and execute the logic.... same setinterval jaise call karta hai


        setti = setTimeout(() => {

            // console.log("Thanks")

        }, 1000);

       

        // ye ek hi bar run karta hai

        setti1 = setTimeout(Greet, 1000,"vishal","Take care");

       

        clearTimeout(setti1)

       

        function Greet(name,ByeText){

            console.log("Hello Good morning,"+ name + " "+ ByeText);

        }


        setInterval(displatDate, 1000);

        function displatDate(){

            time = new Date();

            document.getElementById('time').innerHTML=time

        }

    </script>

</body>

</html>
Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)