我不明白为什么拼接方法对我不起作用。我有一个看起来像这样的数组:(它实际上更大,但我不想弄乱页面)
var navItems = [ {
"content": "Panels",
"icon": "panels"
},
{
"content": "Samples",
"icon": "sample"
}];
我想在中间插入一个项目说:
var testNavItems = navItems.splice(1, 0, {
"content": "New Nav",
"icon": "New Nav"
});
console.log(testNavItems);
或者
var testNavItems = navItems.push({
"content": "New Nav",
"icon": "New Nav"
});
console.log(testNavItems);
我得到一个空数组。这在JS中可能吗?