π©Find and Filter Elements
const month = ['January','February','March','April','May','June','July','August','September','January'];
// Return index of First Occurrence of Element
console.log("First Index = " + month.indexOf('January'));
// Output : First Index = 0
// Return index of Last Occurrence of Element
console.log("Last Index = " + month.lastIndexOf('January'));
// Output : Last Index = 9
// If no element found Return -1
console.log("Nothing Found = " + month.lastIndexOf('November'));
// Output : Nothing Found = -1
// Check if element exists in arrary (if not return false)
console.log("Element Found = " + month.includes('November'));
// Output : Element Found = false
// Check if element exists in arrary (if yes return true)
console.log("Element Found = " + month.includes('April'));
// Output : Element Found = true
Last updated