title: Define a class that extends Function
body: <p>I'm trying to create a class that extends <code>Function</code>. </p>
  
  <pre><code>var MyClass = class MyClass extends Function {
    constructor(func, /*some other things*/) {
      //this is not defined in extended classes for some reason
      var newThis = func;
      //assign other stuff to newThis
      return newThis;
    }
  
    //methods
  
  }
  </code></pre>
  
  <p>At first I thought this would work but an <code>instanceof</code> check revealed that the object created was just a regular function without any of my methods or properties. So then I realised that I need to use the <code>super</code> keyword to <code>construct</code> a <code>Function</code>. </p>
  
  <pre><code>var newThis = super(func.toString().split('(')[1].split(')')[0].split(','),
                      func.toString().split('{')[1].split('}')[0])
  </code></pre>
  
  <p>This works but it doesn't comply with the content security policy (something like that) which means that it won't work in chrome apps. </p>