title: How to create JSON from inputs name and value pairs
body: <p>I'm working on my personal project and I need a little help. I have a table with some inputs which have <code>name</code> and <code>value</code> attributes. The problem is that I need to create a JSON with pairs <code>name</code>:<code>value</code>.
  How do I do something like that with vanilla JS?</p>
  <p>My code to print what I have:</p>
  <pre class="lang-js prettyprint-override"><code>// Get all inputs from table and print name and value
  document.querySelectorAll(&quot;table input&quot;).forEach((e) =&gt; {
      console.log(e.name, e.value);
  });
  </code></pre>
  <p>What I need:</p>
  <pre class="lang-json prettyprint-override"><code>{
    name1: value1,
    name2: value2,
    name3: value3,
    name4: value4,
  }
  </code></pre>