title: Add polyfill code in Angular 2
body: <p>How would I add code of a polyfill in a Angular 2 cli-project?</p>
  
  <p>For example, I would like to use the following polyfill from <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes#Polyfill" rel="noreferrer">Mozilla MDN</a>:</p>
  
  <pre><code>if (!Array.prototype.includes) {
    Object.defineProperty(Array.prototype, 'includes', {
      value: function(searchElement, fromIndex) {
        if (this == null) { throw new TypeError('"this" is null or not defined'); }
        var o = Object(this);
        var len = o.length &gt;&gt;&gt; 0;
        if (len === 0) { return false; }
        var n = fromIndex | 0;
        var k = Math.max(n &gt;= 0 ? n : len - Math.abs(n), 0);
        while (k &lt; len) {
          if (o[k] === searchElement) { return true; }
          k++;
        }
        return false;
      }
    });
  }
  </code></pre>
  
  <p>I found another thread where the polyfill is installed via npm (<a href="https://stackoverflow.com/questions/38836532/how-to-add-web-animations-api-polyfill-to-an-angular-2-project-created-with-angu">How to add Web Animations API polyfill to an Angular 2 project created with Angular CLI
  </a>). But how to do that if there is no npm package? </p>