indefOf 1

indefOf

const beasts = ['ant', 'bison', 'camel', 'duck', 'bison'];

console.log(beasts.indexOf('bison'));
// expected output: 1

Here is what the above code is Doing:
1. The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present.
2. The indexOf() method is case sensitive. For example, the following expression returns -1:

Similar Posts