【发布时间】:2020-07-11 10:15:19
【问题描述】:
我想在向数组添加对象的同时将值推送到数组。这可能吗? 这是我的代码的简短演示:
let abc = [
[],
{}
];
$('form').find('input').each(function() {
// This works but I'd like to do it in one step if possible
abc[0].push(this);
abc[1][this.name] = 'Text';
// I'd like to change it to something like this
abc = [
this,
this.name: 'Text'
];
)};
【问题讨论】:
标签: javascript jquery arrays object