Understanding indexOf() & lastIndexOf() array methods in Javascript | examples
indexOf() The indexof() method returns the first index of the element found in the array. It returns a value of -1 if the element is not found. This method is helpful when you want to check if a given element is present in an array. let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let numberIndex = numbers.indexOf(5); console.log(numberIndex); // 4 If the element is not present, the method returns -1....