<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kush Mantoo on Medium]]></title>
        <description><![CDATA[Stories by Kush Mantoo on Medium]]></description>
        <link>https://medium.com/@kushmantoo495?source=rss-d3bc4df49d1b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*UrgXpESyT4NusFKS</url>
            <title>Stories by Kush Mantoo on Medium</title>
            <link>https://medium.com/@kushmantoo495?source=rss-d3bc4df49d1b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 05:20:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kushmantoo495/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[SetTimeOut()]]></title>
            <link>https://medium.com/@kushmantoo495/settimeout-041437240a42?source=rss-d3bc4df49d1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/041437240a42</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[easy-explanation]]></category>
            <category><![CDATA[settimeout]]></category>
            <dc:creator><![CDATA[Kush Mantoo]]></dc:creator>
            <pubDate>Sun, 01 Feb 2026 15:07:33 GMT</pubDate>
            <atom:updated>2026-02-01T15:07:33.902Z</atom:updated>
            <content:encoded><![CDATA[<p>I am very excited about this setTimeOut , so will try this to oexplain clearly</p><p>Firstly , the simple defination of setTimeOut is that when we try to defer something then this is used , meaning when we try to do something after X amount of Time. Here is an example of the code</p><p>setTimeout(() =&gt; {<br> console.log(“Wake up!”);<br>}, 2000);</p><p>So here we have used the arrow function , if some of you don’t know arrow function , i will explain that later , but for know ,let’s focus on the syntax and the understanding of the code , the syntax is that we have used the keyword setTimeOut() , the code here means that the “Wake up!” will work after 2 seconds.</p><p>But there is a twist , that it is not confirmed , that it will work after 2 seconds , that is minimum , for that i will explain the functionality of setTimeOut , for that it includes the <strong>call stack</strong> , a <strong>web browser</strong> and a <strong>queue</strong> , i will explain that using this example :-</p><p>console.log(“There is a text that will be printed after some time and the time will be given in that “);</p><p>setTimeout(function(){</p><p>console.log(“Printed after 5 seconds due to the use of setTime Out Function “);</p><p>} , 5000);</p><p>here we have set a timeout of 5 seconds and now the functionality , firstly the code goes from head to foot and <strong>firstly the console.log will be sent into the call stack and when it will be printed , it will be popped out of the stack</strong> , then after the s<strong>etTimeout function will be sent into the call stack , then , here is the catch , it sends first this to the web browser and then pops out of the stack</strong> , , so the now the stack is empty and now the time of 5 seconds is running , then it is forwarded to the queue, <strong>now the queue will check if there is anything running in the stack , if it is running </strong>,<strong> then it will wait till the time the stack gets empty </strong>, t<strong>hat’s why i mentioned earlier , that the time is not guaranteed . </strong>And when the stack gets empty , then it will be forwarded to the stack and then the console.log will be printed .</p><p>Now i am sure you have understood this and there is ome more clear TimeOut which clears the timeOut , whicch we have set earlier .</p><p>Now their is a question what is the real life use of this :-</p><ul><li>Loading spinner</li><li>Toast notification</li><li>Auto logout</li><li>Delayed popup</li><li>Retry API</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=041437240a42" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>