title: What are the difference between generic Type(T) vs any in typescript
body: <h2>What is the difference between <code>generic Type(T)</code> vs <code>any</code> in typescript?</h2>
  
  <h2>Function 1</h2>
  
  <pre><code>function identity(arg: any): any {
      return arg;
  }
  </code></pre>
  
  <h2>Function 2</h2>
  
  <pre><code>function identity&lt;T&gt;(arg: T): T {
      return arg;
  }
  </code></pre>
  
  <h2>Function 3</h2>
  
  <pre><code>function identity&lt;T&gt;(arg: T[]): T[] {
      return arg;
  }
  </code></pre>
  
  <hr>
  
  <blockquote>
    <p>Function 1 &amp; 3 is accepted if we passing any kind of <code>data type</code>, But the function 2 does not accept if we pass an <code>array</code>. <strong>generic type is accepting all kind of data type on compile time</strong>. but here why it does not accept? </p>
  </blockquote>
  
  <p><strong><em>Also which function is good for better performance ( function 1 or function 3)?</em></strong></p>