title: How do I initialize an empty array inside a java script object?
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const cart = {
    // I am initializing an empty array
    contents: "[]",
    addItem(item) {
      // I am adding an element to the array
      contents.push(item);
    }
  };
  
  cart.addItem("laptop");
  console.log("The cart contains:", cart.contents);</code></pre>
  </div>
  </div>
  </p>