Currently I'm pushing multiple inputs to a array but this is a lot of repeating code, how can I improve this? var tickets = [];    $('.js-ticket').each(function(){      var ticket = [];      ticket.push($(input[name='ticket_naam\\[\\]']).map(function(){return $(this).val();}).get());      ticket.push($(input[name='ticket_aantal\\[\\]']).map(function(){return $(this).val();}).get());      ticket.push($(input[name='ticket_prijs\\[\\]']).map(function(){return $(this).val();}).get());      ticket.push($(input[name='ticket_begin_datum\\[\\]']).map(function(){return $(this).val();}).get());      ticket.push($(input[name='ticket_begin_tijd\\[\\]']).map(function(){return $(this).val();}).get());      ticket.push($(input[name='ticket_eind_datum\\[\\]']).map(function(){return $(this).val();}).get());      ticket.push($(input[name='ticket_eind_tijd\\[\\]']).map(function(){return $(this).val();}).get());      ticket.push($(input[name='ticket_aanal_max\\[\\]']).map(function(){return $(this).val();}).get());      ticket.push($(input[name='ticket_aanal_min\\[\\]']).map(function(){return $(this).val();}).get());      tickets.push(ticket);    });  historyVar['tickets'] = tickets;  });The Html is reader simple just 9 input fields and i'm running this part on a click of a button  
Push val of input to array
javascript;jquery
Try this out:var tickets = [];var names = [    'ticket_naam', 'ticket_aantal', 'ticket_prijs', 'ticket_begin_datum',    'ticket_begin_tijd', 'ticket_eind_datum', 'ticket_eind_tijd',    'ticket_aanal_max', 'ticket_aanal_min'];$('.js-ticket').each(function() {    var $ticket = $(this);    var ticket = $.map(names, function(name) {        return $ticket.find('input[name=' + name + '\\[\\]]').val();    })    tickets.push(ticket);});The one thing I want to point out is I'm searching within each .js-ticket for the inputs, instead of searching globally each time like your function was. I have to imagine this is what you were intending to do in the first place, otherwise the outer each doesn't make much sense.