title: Javascript's Object(this) usages in polyfills?
body: <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#Polyfill" rel="noreferrer"><strong>I saw here</strong></a> the <code>Array.prototype.forEach()</code>'s polyfill and I have a question about its implementation : </p>
  
  <pre><code>/*1*/   if (!Array.prototype.forEach)
  /*2*/   {
  /*3*/     Array.prototype.forEach = function(fun /*, thisArg */)
  /*4*/     {
  /*5*/       "use strict";
  /*6*/   
  /*7*/       if (this === void 0 || this === null)
  /*8*/         throw new TypeError();
  /*9*/   
  /*10*/       var t = Object(this);
  /*11*/       var len = t.length &gt;&gt;&gt; 0;
  /*12*/       if (typeof fun !== "function")
  /*13*/         throw new TypeError();
  /*14*/   
  /*15*/       var thisArg = arguments.length &gt;= 2 ? arguments[1] : void 0;
  /*16*/       for (var i = 0; i &lt; len; i++)
  /*17*/       {
  /*18*/         if (i in t)
  /*19*/           fun.call(thisArg, t[i], i, t);
  /*20*/       }
  /*21*/     };
  /*22*/   }
  </code></pre>
  
  <p>Looking at line #10 : why did they use <code>Object(this)</code> ? </p>
  
  <p>As  I searched its usages I saw <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" rel="noreferrer">this</a> : </p>
  
  <blockquote>
    <p>The Object constructor creates an object wrapper for the given value.
    <strong>If the value is null or undefined</strong>, it will create and return an empty
    object, otherwise, it will return an object of a type that corresponds
    to the given value. If the value is an object already, it will return
    the value.</p>
  </blockquote>
  
  <p>So they wanted to check if it's <code>null</code>  || <code>undefined</code> .</p>
  
  <p>Ok , 
  But they <strong>already</strong> checked it in lines #7-#8 !</p>
  
  <p>Question : </p>
  
  <p>What is the reason (which I'm missing) that they used <code>Object(this)</code> ? </p>