title: Is there any way to keep track of how many objects I have created with a factory function in JavaScript?
body: <p>Let's say I have a factory like this:</p>
  <pre><code>const itemFactory = () =&gt; {
      const itemName = ''
      const firstMethod = () =&gt; {
          // something goes here
      }
  
      return { itemName, firstMethod }
  }
  </code></pre>
  <p>Is there a way I can keep track of how many items I have created with that function?
  I want to include an index in the <code>itemName</code> property of each item, like this: <code>item0</code>, <code>item1</code>, <code>item2</code>, etc.</p>