So I am still learning arrays and objects, and I'm a little bit stuck. I made an example of array of objects:
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. Question - Why doesn't it work when I write.:
var candy1 = Object.keys(something.candy);
candy1.filter(function(obj){
return console.log(obj.name);
});
Isn't it practically the same code meaning as above?
2.Question How come slice works and splice doesn't???
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));
})