This is just a bit of a nonsense example but it perfectly describes my problem.
The following call of the object's function gives undefined
for bird
property:
const birds = {
species:['Grey tinamou','Greater rhea','Dwarf cassowary'],
bird: 'Bird',
summary: function(){
return this.species.map(function(species) {
return `${species} is a ${this.bird}`;
});
}
};
birds.summary();
1) How can I access the bird
property in the object's function?
2.1) Can I do this without passing in the bird
property's value itself?
Like this: birds.summary(birds.bird);
2.2) is there a better/another way to do that?