title: Create an object dynamically from a .each() jquery
body: <p>I need to create dynamically a simple object like this one</p>
  <pre><code>var markers = {
      0 : { &quot;group&quot;:1, &quot;icon&quot;:&quot;plus&quot; },
      1 : { &quot;group&quot;:2, &quot;icon&quot;:&quot;cross&quot; },
      2 : { &quot;group&quot;:2, &quot;icon&quot;:&quot;minus&quot; },
  };
  </code></pre>
  <p>...from a jquery loop .each() to get data from the Dom. I tried this without success:</p>
  <pre><code>var markers = {};
  $('.markers').each(function(i) {
      let group = { group: $(this).data(&quot;group&quot;) };
      let icon = { icon: $(this).data(&quot;icon&quot;) };
      let obj = {group, icon};
      markers[i] = {arr};
  });
  </code></pre>
  <p>I come from php and I still don't understand multidimensional array in javascript (or objects in that case). Thank you in advance for any help.</p>