📜  indexof js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:04.703000             🧑  作者: Mango

代码示例6
const fruits = ["apple", "banana", "cantaloupe", "blueberries", "grapefruit"];

const index = fruits.findIndex(fruit => fruit === "blueberries");

console.log(index); // 3
console.log(fruits[index]); // blueberries