title: List of class instances in JS via static variable
body: <p>I am trying to emulate the following class in js. This is Python, but I hope the intent is clear. I wish to have a static variable that contains a reference to every instance of the class. Thus I want to add every instance to the variable during construction.</p>
  
  <pre><code>class Foo:
      allFoos = [] # static variable
  
      # Constructor
      def __init__(self):
          allFoos.append(self)
  </code></pre>
  
  <p>I am using ES6 classes (see <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes" rel="nofollow noreferrer">mdn</a>) and haven't been able to manage this. What is the js analogue of the code above?</p>