![]() ![]() The Array.includes() method is a really handy way to quickly check if a given array does - or does not - include a particular value. check if designTeam contains 'April' on second half of teamĭesignTeam.includes('April', (designTeam.length / 2)) // returns false In the example below we have an array of the two teams containing their respective employees: const devTeam = Ĭonst designTeam = ĭevTeam.includes('Mitch') // returns false They could use the Array.includes() method to confirm one way or the other rather quickly. Let's imagine that a manager wanted to confirm whether one of their employees, Jose, was on the designTeam or the devTeam. □ Note: If valueToFind is not specified, it defaults to 0. fromIndex is the index at which to start looking for the valueToFind. ![]() valueToFind is the value that is being searched for.The Array.includes() method looks through an entire array and determines if the specified value exists in the array, returning a boolean value accordingly. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |