所以我还在学习数组和对象,我有点卡住了。
我举了一个对象数组的例子:
var something = {candy:[{name:"snickers", price:2},
{name:"bounty", price:3},
{name:"mars", price:4}]};
Object.keys(something.candy).filter(function(obj){
return console.log(something.candy[obj].name);
})
1.问题-为什么我写作时它不起作用:
var candy1 = Object.keys(something.candy);
candy1.filter(function(obj){
return console.log(obj.name);
});
2.问题:为什么切片工作而拼接不工作???
Object.keys(something.candy).filter(function(obj){
return console.log(something.candy[obj].name.slice(0,3));
})
Object.keys(something.candy).filter(function(obj){
return a(something.candy[obj].name.splice(1,3));
})