📜  打字稿代码示例中 .include 的替代方法

📅  最后修改于: 2022-03-11 14:48:24.643000             🧑  作者: Mango

代码示例1
let shoppingList: string[] = [
  'Eggs',
  'Milk',
  'Fish',
  'Apple',
  'Bread',
  'Chicken',
];

function isThere(arr: string[]): void {
  let there1: boolean = arr.indexOf('Milk') > -1;
  let there2: boolean = arr.indexOf('Banana') > -1;

  console.log(there1);
  console.log(there2);
}

isThere(shoppingList);