8.3.1. Common Array Methods // includes Examples (.includes)
//The general syntax for this method is:
arrayName.includes(item)
/*This method checks if an array contains the item specified in the
parentheses (), and returns true or false.*/
let charles = [1, 7, 5, 9, 5];
let otherArr = ['hello', 'world!'];
console.log(charles.includes(5));
console.log(otherArr.includes('hi'));
//true
//false
Are there any code examples left?
New code examples in category Javascript