How to use a generic expression as class getter
<p>Is it possible to use a regular expression as generic getter expression of a Class in JS? Works just fine if test is replaced by <code>"bar"</code>.</p>

<p>If not, is there an other way to create a generic getter for a class?</p>

<pre><code>var test = /^(?!foo).*$/;

var Foo = class {
   get foo() {
      return 'foo!';
   }
   get [test]() {
      return 'the called getter was ' + this.expr;
   }
}

var f = new Foo();

console.log(f.bar)
</code></pre>