<?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 Mohammad Yasir on Medium]]></title>
        <description><![CDATA[Stories by Mohammad Yasir on Medium]]></description>
        <link>https://medium.com/@yasir-24043?source=rss-3e405699fd0d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*14KLZfiQCvecw2JG.jpg</url>
            <title>Stories by Mohammad Yasir on Medium</title>
            <link>https://medium.com/@yasir-24043?source=rss-3e405699fd0d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 22:21:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yasir-24043/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[Destructuring assignment in JavaScript]]></title>
            <link>https://yasir-24043.medium.com/destructuring-assignment-in-javascript-cbd9a6aa1d4c?source=rss-3e405699fd0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbd9a6aa1d4c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es6]]></category>
            <dc:creator><![CDATA[Mohammad Yasir]]></dc:creator>
            <pubDate>Wed, 17 Feb 2021 10:37:37 GMT</pubDate>
            <atom:updated>2021-02-17T10:39:21.966Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*oJmmE5CAmb1qiW6WPOiNgw.png" /></figure><p>Destructuring assignment in JavaScript is used to unpack(retrieve) the value from Array or Object with easy way.</p><p>Now Look at a code , where we unpack value from Array and Object without using Destructuring assignment.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d52b94e946cceac2f168686819e4056/href">https://medium.com/media/8d52b94e946cceac2f168686819e4056/href</a></iframe><p>Now, See how we can achieve the same thing using destructuring.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/abaa36757df7171bc4467f6fea1412bb/href">https://medium.com/media/abaa36757df7171bc4467f6fea1412bb/href</a></iframe><p>No if we compare the both methods, We find that using destructuring makes its easy &amp; simple.</p><p>For ex. we can see that there are repetition of codes in first method (we have to type many times ‘arr’ and ‘obj’), But in case of destructuring, there are no repetition.</p><p><strong>Some advance feature in object destructuring:</strong></p><p>Now let supose , you want to use varaibles with some other name:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7241007011662dbbeba7b2c54089af68/href">https://medium.com/media/7241007011662dbbeba7b2c54089af68/href</a></iframe><p>Please note here if we use x,y,z , it will not work &amp; it will throw the error (Uncaught ReferenceError)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbd9a6aa1d4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Callback Function in JavaScript]]></title>
            <link>https://yasir-24043.medium.com/callback-function-in-javascript-5cc6ead5a264?source=rss-3e405699fd0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cc6ead5a264</guid>
            <dc:creator><![CDATA[Mohammad Yasir]]></dc:creator>
            <pubDate>Wed, 23 Dec 2020 11:51:49 GMT</pubDate>
            <atom:updated>2021-02-17T13:29:41.591Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Callback Function:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*oJmmE5CAmb1qiW6WPOiNgw.png" /></figure><p>When we call a function , we may pass some data as an arguments to that function like 1,2,”Car” etc,But in JavaScript , it is possible to pass a function as an argument to that function as well.</p><p>These Function are called <strong><em>callback function</em></strong>.So it’s the parent function(the function in which callback function is passed as an argument),will call this function in it’s body when required.</p><p><strong>Let’s understand this with code example.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f00fd3787d90d950ae146f3adcca86a/href">https://medium.com/media/5f00fd3787d90d950ae146f3adcca86a/href</a></iframe><p>Here in above example the function “childFunction” is used as <strong><em>callback function</em></strong>,And the function “parentFunction” is calling this callback function in it’s body.</p><p>One thing also need to notice here that, the function Which take a function as parameter are called high order function. So it this example the function “parentFunction” is a <strong><em>high order function</em></strong> which is taking “childFunction” as a parameter.</p><p><strong>Examples of callback we frequently use :</strong></p><p>If you know the basic of JavaScript, You probably have used filter,map,findIndex etc. of array in JavaScript. So these all function takes another function as a parameter.</p><p>Now let’s talk about filter function, it will call your function that you passed with n times(n= length of array),And its return an filtered array, Which includes the items for which your function returns true.</p><p>Also filter,map,findIndex etc are <strong><em>high order function</em></strong> order function because they all take a function as a parameter.</p><p><strong>Conclusion:</strong></p><p>From above explanations, it clear that when a function as passed as an argument in another function are called callback function, And when a function receive another function as a parameter are called high order function.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cc6ead5a264" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debouncing & Throttling]]></title>
            <link>https://yasir-24043.medium.com/debouncing-throttling-3153ae33c3d1?source=rss-3e405699fd0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3153ae33c3d1</guid>
            <category><![CDATA[throttling]]></category>
            <category><![CDATA[javscript]]></category>
            <category><![CDATA[debouncing]]></category>
            <dc:creator><![CDATA[Mohammad Yasir]]></dc:creator>
            <pubDate>Wed, 09 Dec 2020 12:59:33 GMT</pubDate>
            <atom:updated>2020-12-10T09:08:33.046Z</atom:updated>
            <content:encoded><![CDATA[<h3>Debouncing &amp; Throttling:</h3><p>Debouncing &amp; Throttling are the techniques to optimise the system. Basically these are used to prevent the too much function calls. let discuss one by one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*oJmmE5CAmb1qiW6WPOiNgw.png" /></figure><p><strong>Debouncing:</strong></p><p>Let suppose a situation, that we have system where we are searching the product, and making the Api calls whatever user types on input box, so let suppose he types “mobile”, So normally there will be 6 Api calls. which looks like,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/979e50ec77f8ab2df85c71d8d3e2c86e/href">https://medium.com/media/979e50ec77f8ab2df85c71d8d3e2c86e/href</a></iframe><p>So if our will look like this, this will leads to performance issue,</p><p>So the solution is to apply here Debouncing technique , so lets say when user takes a pause of certain time ie 300ms, then only we will call that Api. This is same like when someone is asking something to us, we don’t reply immediately ,we reply when he takes some pause.</p><p><strong>Code implemenation:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/857726fea0028087d97e72bee7902e0f/href">https://medium.com/media/857726fea0028087d97e72bee7902e0f/href</a></iframe><p>In this code , whenever user will type , the Api will called after 300ms . if user doest’t take pause of 300ms &amp; continue typing, code will clear the previous timer and will make new timer of 300ms. So in this way the Api will only called when user takes pause of 300ms.</p><p>So by applying Debouncing here , it reduces number of Api calls.</p><p><strong>Throttling:</strong></p><p>Let suppose a situation, we have Shooting game, so when we press button, it’s need to fire . Also the guns have some reload time ie 500ms. So if user press 5 times that button immediately, it should fire only once instead of 5 times, Next fire should allowed only after 500ms.</p><p>So here we can use concept of Throttling.</p><p><strong>Code implementation:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/454228c71228b8bcc2c94ee8dbc6d2be/href">https://medium.com/media/454228c71228b8bcc2c94ee8dbc6d2be/href</a></iframe><p>In this code, it will check if “allowed” is true, it will call fire function , and then it make “allowed” to false and set a timer of 500ms to make it again true.</p><p>So in this case, if someone press button before that time, it will not call the fire function because “allowed” is false, and after completing 500ms it will again set it to true, then user will able to fire.</p><p><strong>Difference between Debouncing &amp; Throttling:</strong></p><p>In Throttling time to wait is always constant, no matter how many times we press that button , it will always allow to call the function after completing that specific time,But in case if Debouncing , if we press button before that specific time then we have to again wait for whole time limit not the remaining time.</p><p>Let say we type “a” and after 100ms we type “b” then waiting time will again 300ms not 200ms(300ms — 100ms). But In case of Throttling, waiting will be the remaining time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3153ae33c3d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>