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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |