Adding items to an object through the .push() method

后端 未结 5 419
Happy的楠姐
Happy的楠姐 2020-12-04 08:15

I\'m doing a loop through few input elements of \'checkbox\' type. After that, I\'m adding values and checked attributes to an array. This is my code:

var st         


        
5条回答
  •  借酒劲吻你
    2020-12-04 08:45

    Another way of doing it would be:

    stuff = Object.assign(stuff, {$(this).attr('value'):$(this).attr('checked')});
    

    Read more here: Object.assign()

提交回复
热议问题