I was hoping someone could help me understand something about the '.includes' method.
My understanding was that this only worked on arrays? for e.g. myarray.includes('something').
But it also seems to work when you loop over the array and use it on an object for e.g:
var people = [
{
name: 'Joe',
age: 27
},
{
name: 'Rob',
age: 25
},
{
name: 'Dave',
age: 22
}
];
for(i=0; i<people.length; i++) {
console.log(people[i].name.includes('Joe')) // True
}
Can someone explain why this is?
Thanks,
Joe