Skip to content

Array.prototype.includes

作用

  • 数组的 Includes() : 用来检测数组中是否包含某个元素,返回true/false

  • 字符串也有includes方法

特点

js
let a = [1, 2, 3, 4];
// 判断
console.log(a.includes(1)); // true

let b = 'hello world';
console.log(b.includes('h')); // true

Released under the MIT License.