For exemple, i have 3 inputs
Use JavaScript object instead of an array. To create a object key you just have to declare it between the brackets [ ] and assign a value.
var obj = {}; var x = document.querySelectorAll('input'); for (var i = 0; i < x.length; i++) { obj[x[i].name] = x[i].value } console.log(obj);