<?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: Pawan Poojary</title>
    <description>The latest articles on DEV Community by Pawan Poojary (@pawan16123).</description>
    <link>https://dev.to/pawan16123</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F975864%2Fead4c507-d752-4e4b-926c-b72ad2cbeada.png</url>
      <title>DEV Community: Pawan Poojary</title>
      <link>https://dev.to/pawan16123</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pawan16123"/>
    <language>en</language>
    <item>
      <title>Javascript most asked polyfills</title>
      <dc:creator>Pawan Poojary</dc:creator>
      <pubDate>Thu, 09 Feb 2023 04:13:51 +0000</pubDate>
      <link>https://dev.to/pawan16123/javascript-most-asked-polyfills-25e3</link>
      <guid>https://dev.to/pawan16123/javascript-most-asked-polyfills-25e3</guid>
      <description>&lt;p&gt;&lt;strong&gt;ForEach Polyfill:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Array.prototype.forEachPoly = function(cb){

    for(let i = 0; i &amp;lt; this.length; i++){
        cb(this[i], i, this);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Map Polyfill:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Array.prototype.mapPoly = function(cb){
    let newArr = [];
    for(let i=0; i&amp;lt;this.length; i++){
        newArr.push(cb(this[i], i, this));
    }
    return newArr;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Filter Polyfill:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Array.prototype.filterPoly = function(cb){
    let newArr = [];
    for(let i=0; i&amp;lt;this.length; i++){
        if(cb(this[i], i, this)){
            newArr.push(this[i]);
        }
    }
    return newArr;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Reduce Polyfill:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Array.prototype.reducePoly = function(cb, optionalInitilizer){
    console.log(optionalInitilizer);
    let acc, i;
    if(optionalInitilizer !== undefined){
        acc = optionalInitilizer;
        i=0
    }else{
        acc = this[0];
        i=1;
    }

    for(i; i&amp;lt;this.length; i++){
        acc = cb(acc, this[i],i,this)
    }
    return acc;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;OR&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Array.prototype.reducePoly2 = function(cb, initializer){
    let acc = initializer;
    for(let i=0; i&amp;lt;this.length; i++){
        acc = acc ? cb(acc, this[i], i, this) : this[0];
    }
    return acc;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Call Polyfill:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Function.prototype.callPoly = function(context={}, ...args){
    context.func = this;
    context.func(...args);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Apply Polyfill:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Function.prototype.applyPoly = function(context={}, args){
    context.func = this;
    context.func(...args);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Bind Polyfill:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Function.prototype.bindPoly = function(context={}, ...args){
    let reqFunc = this;
    return function(...newArgs){
        context.func = reqFunc;
        context.func(...args, ...newArgs);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>bind</category>
      <category>promise</category>
      <category>reduce</category>
      <category>filter</category>
    </item>
  </channel>
</rss>
