DEV Community

SELVAKUMAR R
SELVAKUMAR R

Posted on

synchronous, Asynchronous,Callback Hell,Promise In Java Script

Synchronous

Synchronous is execute the code line by line.

Synchronous is wait for the one action complete and block the other action to perform.

<body>
    <Script>

        // synchronous in Java Script

        console.log("Selva");
        console.log("kumar");
        console.log("Ramesh");

        </Script>
</body>
Enter fullscreen mode Exit fullscreen mode

Output:

ASynchronous:

ASynchronous is not waiting for the execution of one function complete

<body>
    <script>
        console.log("Selva");

        setTimeout(() => {
            console.log("Kumar")
        }, 1000);

        console.log("Ramesh");

    </script>
Enter fullscreen mode Exit fullscreen mode

Output:

Top comments (0)