Array.prototype.includesintermediateconst arr = [1, 2, 3]
// verbose:
arr.indexOf(2) !== -1 // β true
// cleaner:
arr.includes(2) // β truePrefer includes() over indexOf() !== -1 when you only need a boolean result.
Both includes() and indexOf() can find null. However, includes() returns a clean boolean, while indexOf returns a number that must be checked against -1. Use includes() when you only need to know if a value is present.
Challenge: Implement containsNull(arr) that returns true if the array contains null using arr.includes(null).
containsNull([1, null, 3]) // β true
containsNull([1, 2, 3]) // β false