-->

  • Question from setTimeout in Javscript

     

    Question from setTimeout in Javscript

     

    Hello viewers, whats up!! Here i am back again with the new post of question about setTimeout in javascript. Javascript is a high level programming language used for known as web development. With this you can create dynamic and interactive content on websites.

    Syntax is similar to that of other programming languages like java and C. It is client side scripting language and when we talk about its Data types , it is support various data types, including numbers, strings booleans objects, arrays and functions.


    Here we have a problem about setTimeout in javascript. Question is that there so 6 line of code in javascript. So simply use arrow function and for output we use console.log and after that we have to used setTimeout function and tell that what is the output and which output print first. Look like this -

     

    Code 

     

     

    (function() {
          console.log("a");
          setTimeout(() => console.log("b"), 1000);
          console.log("c");
          setTimeout(() => console.log("d"), 500);
    })();
    

     

     

     

    1) console.log("a"); - Outputs "a" to the console.


    2) setTimeout(() => console.log("b"), 1000); - Schedules the execution of the function () => console.log("b") after a delay of 1000 milliseconds (1 second).
       
     
    3) console.log("c"); - Outputs "c" to the console.
        

    4) setTimeout(() => console.log("d"), 500); - Schedules the execution of the function () => console.log("d") after a delay of 500 milliseconds (0.5 seconds).


    Now, let's consider the timing:


    #:/    "a" is logged immediately.
    #:/    "b" is scheduled to be logged after 1 second.
    #:/    "c" is logged immediately.
    #:/    "d" is scheduled to be logged after 0.5 seconds.


    However, JavaScript is single-threaded, and the event loop is used to manage the execution of asynchronous code. The scheduled functions (like "b" and "d") are placed in the event queue and executed when the call stack is empty.



    So, the output order will be:

     

     

        "a"
        "c"
        "d"
        "b"
    
    
    

     

     

    Question from setTimeout in Javscript

     

     

     


    # Install redux and saga packages - CLICK HERE

    # Make reducer wrapper - CLICK HERE

    # Action in reducer - CLICK HERE

    # Reducer in redux - CLICK HERE

    # Switch Stmt in redux - CLICK HERE

    # Get data in component from redux - CLICK HERE 

    # Remove from cart - CLICK HERE 

    # Add Redux Toolkit in react redux saga - CLICK HERE  

    # Configure MiddleWare saga - CLICK HERE   

    # Call API with Saga and Set Result in react redux saga - CLICK HERE    

    # Product list ui with API data in react redux saga - CLICK HERE    

    # Remove to Cart with ID react redux saga - CLICK HERE     

    # Add Routing and Make Cart Page - CLICK HERE   

    # Show Added To Cart Product with Price Calculation  - CLICK HERE  

     

    Disclaimer



    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.

     

     

     

  • 0 comments:

    Post a Comment

    For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.