<?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 Naseeb Shah on Medium]]></title>
        <description><![CDATA[Stories by Naseeb Shah on Medium]]></description>
        <link>https://medium.com/@lineo3551?source=rss-24d0578b4f97------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hx4HxbVUovKihdiaHSv1Lw.jpeg</url>
            <title>Stories by Naseeb Shah on Medium</title>
            <link>https://medium.com/@lineo3551?source=rss-24d0578b4f97------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 15:41:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lineo3551/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[Generator in JavaScript]]></title>
            <link>https://medium.com/@lineo3551/generator-in-javascript-fda8812e6b3c?source=rss-24d0578b4f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/fda8812e6b3c</guid>
            <category><![CDATA[masai-school]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[webdev]]></category>
            <dc:creator><![CDATA[Naseeb Shah]]></dc:creator>
            <pubDate>Fri, 07 Oct 2022 09:20:13 GMT</pubDate>
            <atom:updated>2022-10-07T09:20:13.194Z</atom:updated>
            <content:encoded><![CDATA[<p>What is the generator Function in JavaScript ? that question asks many times in frontend developer Interviews. Today we are discussing <br>generator function in JavaScript.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pCpCso2rN1NWvOSE" /></figure><p>A generator function that returns the Generator Object. It’s defined by a function keyword followed by a (*)asterisk, as shown following example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*QPcRi758rpn0oOlrcNzpoQ.png" /></figure><p>The generator function can also be defined in an expression, Like a regular function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*U6_CJXXQ1DeTQo6fWegYVQ.png" /></figure><p>Above I say that the generator function returns a Generator Object.<br>Get a Quick Overview of the Generator Object -</p><p>Generator function return a object which includes two key one is value another one is “done”. let see below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*wn77Pohqj4UvgOmb9y27Pg.png" /></figure><p>*If familiar with the link list, you can say the generator function is a link list, and it’s stored in one single memory location. It’s called by the next() keyword. For every single call the function executes a single yield code block, in the next call executes the next yield code block .when execution reaches return keyword , its done value became true.</p><p>Here is how his program works:</p><p>1. The first <strong><em>call.next</em></strong><em>() statement executes the code up to the first yield statement and pauses the execution of the program.</em></p><p>2. The second <strong><em>call</em></strong><em>.</em><strong><em>next(</em></strong><em>) start the program from the paused position and execute till the next yield statement .</em></p><p><em>3 .When all the elements are accessed , it returns done : true .</em></p><p><strong>Generator Method:</strong></p><p>1 <strong>next() : </strong>Returns a value of yield.</p><p>2 <strong>return() : </strong>Returns a value terminates the generator.</p><p>3 <strong>throw()</strong> :Throws an error and terminates the generator.</p><p><strong>Uses of Generator Function :</strong></p><ol><li>Generators let us write cleaner code while writing asynchronous tasks.</li><li>Generators provide an easier way to implement iterators.</li><li>Generators execute its code only when required.</li><li>Generators are memory efficient.</li></ol><p><strong>Please give your valuable feedback and suggestions.<br>Thanks.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fda8812e6b3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Promises In JAVASCRIPT]]></title>
            <link>https://medium.com/codex/promises-in-javascript-e577ca256e72?source=rss-24d0578b4f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/e577ca256e72</guid>
            <category><![CDATA[promises]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Naseeb Shah]]></dc:creator>
            <pubDate>Wed, 22 Jun 2022 11:12:43 GMT</pubDate>
            <atom:updated>2022-06-23T16:11:49.266Z</atom:updated>
            <content:encoded><![CDATA[<p>The promise is a JS special object. It produces value after an asynchronous operation is completed successfully or not. If it’s successful then perform a task which is defined resolve part. other hands, operation not successful code will be executed from the reject part.</p><p><strong>Simply Promises is a JavaScript Object that links producing code and consuming code.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*xQWwrLuQGF2deD-qhln-yg.png" /></figure><p>As you can see above example, line 1 we are producing a promise and this line has that function called the executor function. And after successful completion make a call then function and then is consumer function.</p><h3>Understanding Promise States</h3><p>Promises can be created by with the constructor syntax like this:___</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*_O_W5-UYpyDmusqmvMPagQ.png" /></figure><p>The constructor function takes a function as an argument that is called the the executor function.</p><p>A promise has the following internal properties :<br><strong>State: This property has three values .Pending , Fulfilled and Rejected.</strong></p><ol><li><strong>Pending-<br> </strong>When the executor function start execution.</li><li>Fulfilled- When promises is resolved.</li><li>Rejected- When promises is rejected.</li></ol><p><strong>Result- This property has again three values.</strong></p><ol><li>undefined — when the state is pending.</li><li>value — when promises resolved (value) is called value.</li><li>error — when promises rejected(error) is called error.</li></ol><p><strong>How to handle once promises you are created it</strong></p><p>A promise uses an executor function to complete a task (mostly asynchronously).A consumer function should get notified when the executor function is done. The handler methods, .then(), .catch() and .finally(), help to create the link between the executor and the consumer functions so that they can be in sync when a promise resolves or rejects.</p><p>If the promise is fulfilled then the response goes to the .then() method for further actions .The promise is rejected the response goes to .catch() function.</p><p><strong>Please give your valuable feedback and suggestions.<br>Thanks.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e577ca256e72" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/promises-in-javascript-e577ca256e72">Promises In JAVASCRIPT</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Asynchronous And Synchronous In JS]]></title>
            <link>https://medium.com/@lineo3551/asynchronous-and-synchronous-in-js-87afed8b6ab?source=rss-24d0578b4f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/87afed8b6ab</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript-development]]></category>
            <dc:creator><![CDATA[Naseeb Shah]]></dc:creator>
            <pubDate>Tue, 21 Jun 2022 01:48:51 GMT</pubDate>
            <atom:updated>2022-06-21T01:48:51.945Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Synchronous</strong>:- As the name suggests synchronous means to be the sequence. The tasks were completed in sequence. If the first task is completed then only one can move on to the second task.</p><p>Simply, you can say that code is executed line by line .before going next task you should complete the previous task.<br>let us understand with the help of an example:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tj7V03oNND32LCDFSrBdWA.png" /><figcaption><a href="https://replit.com/@SCION-OFOF/blogJavaScript#Synchronous%20JavaScript.js">https://replit.com/@SCION-OFOF/blogJavaScript#Synchronous%20JavaScript.js</a></figcaption></figure><p>As you can code executed line by line this is Synchronous Programming.</p><p><strong>Asynchronous :- </strong>In synchronous, the code is executed line by line, there is no problem if the code execution takes a small time, Synchronous is doing well. On the other hand, if the program is large and takes little time to execution when Asynchronous come to picture it allows multitasking that does not await whether the previous one is completed or not.</p><p>Simply You Can Say that function runs with parallel other function which is called Asynchronous .like as setTimeout() Etc. One thing to note is JavaScript is a single-thread language. JavaScript relies on the <strong>call stack</strong> to perform asynchronous tasks.</p><p>let us understand with help of an example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*4FdBwfyJJc_t6LxXCkSagw.png" /></figure><p>As you can see, the above code output should be “Start Mid-Operation End”. The setTimeout function takes 3 seconds to execute, the JS engine has registered this function in the call stack, it doesn’t wait for 3 seconds and proceeds to the next line execution. A good example of Asynchronous.</p><p>Asynchronous says that=&gt;I WILL FINISH LATER!</p><p>About call stack<br> Will discuss in the next blog.</p><p><strong>Please give your valuable feedback and suggestions.<br>Thanks.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87afed8b6ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IIFE(Immediately Invoked Function Expression) JavaScript]]></title>
            <link>https://medium.com/@lineo3551/iife-immediately-invoked-function-expression-javascript-6449950b8915?source=rss-24d0578b4f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/6449950b8915</guid>
            <dc:creator><![CDATA[Naseeb Shah]]></dc:creator>
            <pubDate>Sun, 19 Jun 2022 04:00:53 GMT</pubDate>
            <atom:updated>2022-06-19T04:00:53.706Z</atom:updated>
            <content:encoded><![CDATA[<p>IIFE is a function that runs as soon as it is defined. We can construct the IIFE function by wrapping it in parentheses and adding a parenthesis at the end of the function. For example :-(<strong>function() { <em>// Code that runs in your function</em> })()</strong></p><p>The function consists of two-part of codes. In the first part, the declaration of function (function code ) is enclosed by parentheses. In the second part, “()” a grouped parentheses, the JavaScript engine will interpret the function directly.</p><h3><strong>Syantax</strong></h3><p><em>( function(){</em></p><p><em>code that runs</em></p><p><em>})()</em></p><p>In ES6</p><p>(()=&gt;{})()</p><p>Let us try to understand the IIFE method using the following example:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*6DrS5phpYlCbEBWsQrlfPA.png" /><figcaption>Immediately Invoked Function Expression</figcaption></figure><p>ES6</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1L0RtFRnhowKOjZujaOzpw.png" /></figure><p>Some important info about IIFE<br>1. That variable declare inside immediately Invoked function expression will be not available outside the function.<br>2. IIFE function can be named or anonymous.<br>3. IIFE is the function able to use parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*iZW7no57v91uiCR40w5lXA.png" /><figcaption>IIFE with parameters</figcaption></figure><p><strong>Please give your valuable feedback and suggestions.<br>Thanks.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6449950b8915" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Closure in JS]]></title>
            <link>https://medium.com/codex/closure-in-js-7cb0c4d592b?source=rss-24d0578b4f97------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cb0c4d592b</guid>
            <category><![CDATA[closure]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[masai-school-journey]]></category>
            <dc:creator><![CDATA[Naseeb Shah]]></dc:creator>
            <pubDate>Sat, 18 Jun 2022 05:34:03 GMT</pubDate>
            <atom:updated>2022-06-23T13:11:35.310Z</atom:updated>
            <content:encoded><![CDATA[<p>The closure is a concept in JavaScript. This is a widely confusing concept that is asked in common interviews with web developers.<br>We will discuss this concept in this blog.</p><p>Before moving on, we will get acquainted with the variable scope in JavaScript.</p><p>JS has three types of scope.</p><p>Global Scope:- A variable declared outside the function called the global scope variable. You can access these variables anywhere in the javascript program.</p><p>Local Scope:- A variable declared within function and you can not access these variables outside function.</p><p>If a variable declared with “let or var” is mutable. You can change the value of this variable at any time. And the other hand, “const” declared variables are unmutable in nature. You cannot change this variable value.</p><h3>Closure:- In JavaScript ,a closure in a function that references variables in the outer scope form its inner scope. The closure preserves the outer scope its inner scope.</h3><p>Simply, a closure can be defined as JS features that include two functions nested or return types, the child function having access to the parent function variable. You can say that, to provide a function global scope variable, another function is created. : — — S&amp;D Shah</p><p>Let us see how closure works with the help of an example:-</p><figure><img alt="The above code an example of a simple closure function." src="https://cdn-images-1.medium.com/max/473/1*7F_SXbgzJ8Sxbw3jBoG2qg.png" /></figure><p>The above code is an example of a simple closure function. In this code there were two functions named child and parent. The child function accesses the parent function variable “ g__var” inside the child function. As you can see, the parent function provides the accessibility of the child variable to the child function.</p><h3>What is the practical use for closure in JavaScript?</h3><ol><li>Using private variables and methods</li><li>Maintaining state between each function call:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*irYFeaLKOHOuDBAnyQP8hw.png" /><figcaption>Using private variables and methods</figcaption></figure><p>The above code is closure with function private variables and methods. There are main function is setrentvalue and when we are passing arguments in setrentvalue, then set the initial value of the rent variable. And its make global type scope for methods . The method uses this variable like as globally variable and we can perform a variety operations like increment rent and decrement rent etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*0RaZdB1nMH594oKlfjV1rA.png" /><figcaption>Maintaining state between function calls</figcaption></figure><p>The above code main condition between function calls. As you can see when we make the first call at that time multivalue = 9 and after calling this for the next call multi the initial value is equal to the starting value of multi 9 * 2 = 18. 18. Value multiples like previous equal multiple value.</p><p>………………………………… Thanks ………………………………</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cb0c4d592b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/closure-in-js-7cb0c4d592b">Closure in JS</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>