Includes()
Given data:
const items = [
{ name: 'Bike', price: 100 },
{ name: 'TV', price: 200 },
{ name: 'Album', price: 10 },
{ name: 'Book', price: 5 },
{ name: 'Phone', price: 500 },
{ name: 'Computer', price: 1000 },
{ name: 'Keyboard', price: 25 }
]
Includes Method
When you have a simple array and you just want to find out where a value is contained within it. Simple question, simple answer.
const items = [1, 2, 3, 4, 5]
const includesTwo = items.includes(2)
console.log(includesTwo)
Result:
true