<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: AR Addula</title>
    <description>The latest articles on DEV Community by AR Addula (@araddula).</description>
    <link>https://dev.to/araddula</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F647016%2Fe656cf77-5022-458c-8914-ff53bd884bec.png</url>
      <title>DEV Community: AR Addula</title>
      <link>https://dev.to/araddula</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/araddula"/>
    <language>en</language>
    <item>
      <title>JS Polyfills - Call, Apply, Bind</title>
      <dc:creator>AR Addula</dc:creator>
      <pubDate>Thu, 10 Jun 2021 16:09:05 +0000</pubDate>
      <link>https://dev.to/araddula/js-polyfills-call-apply-bind-109i</link>
      <guid>https://dev.to/araddula/js-polyfills-call-apply-bind-109i</guid>
      <description>&lt;p&gt;If you are here, I guess you would either be looking for new opportunities or honing your skills. I would like to help for either reasons with this article. Let's directly jump in to the topic without wasting our read time 🤘&lt;/p&gt;

&lt;h2&gt;
  
  
  Polyfill for Call
&lt;/h2&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  Explanation:
&lt;/h3&gt;

&lt;p&gt;What exactly is this 🧐 -&amp;gt; &lt;code&gt;arguments[0].fn = this;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In this above statement &lt;code&gt;this&lt;/code&gt; refers to calling function i.e; &lt;code&gt;displayUser&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We are creating a property(fn) on object and assigning displayUser function to it&lt;/li&gt;
&lt;li&gt;Above would create an additional property &lt;code&gt;fn&lt;/code&gt; on the passed object(user)&lt;/li&gt;
&lt;li&gt;Now, &lt;code&gt;fn&lt;/code&gt; would have access to &lt;code&gt;this&lt;/code&gt; on user object as &lt;code&gt;fn&lt;/code&gt; is user objects property now&lt;/li&gt;
&lt;li&gt;So, pass only parameters now to function &lt;code&gt;fn&lt;/code&gt; now, as it takes care of &lt;code&gt;this&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Both &lt;code&gt;runCall&lt;/code&gt; and &lt;code&gt;runCall2&lt;/code&gt; are valid polyfills for &lt;code&gt;call&lt;/code&gt; where &lt;code&gt;runCall2&lt;/code&gt; has defined parameters and &lt;code&gt;runCall&lt;/code&gt; depends on &lt;code&gt;arguments&lt;/code&gt; object&lt;/li&gt;
&lt;li&gt;Look at the code below and compare with lines written inside function &lt;code&gt;runCall&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Polyfill for Apply
&lt;/h2&gt;

&lt;p&gt;Apply polyfill is similar to call except that &lt;code&gt;apply&lt;/code&gt; takes arguments as Array along with object(context)&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Polyfill for Bind
&lt;/h2&gt;

&lt;p&gt;Here comes the solution for our wait, atleast I feel though 😉&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;There are two functions created for bind polyfill in the above code. One is using &lt;code&gt;[].slice.call(arguments)&lt;/code&gt; and the other one is using rest/spread syntax &lt;code&gt;...arguments&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Thank you for taking time to read my article. I know there would always be something to improve. Please feel free to share your thoughts&lt;/em&gt; 👐&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>javascript</category>
      <category>es6</category>
      <category>polyfills</category>
      <category>interview</category>
    </item>
  </channel>
</rss>
