const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.includes("Mango");
Try it Yourself »
Start the search at position 3:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.includes("Banana", 3);
Try it Yourself »
The includes()
method returns true
if an array contains a specified value.
The includes()
method returns false
if the value is not found.
The includes()
method is case sensitive.
array.includes(
element,
start)
Parameter | Description |
element | Required. The value to search for. |
start | Optional. Start position. Default is 0. |
Type | Description |
A boolean | true if the value is found, otherwise false . |
includes()
is an ECMAScript7 (ES7) feature.
ES7 (JavaScript 2016) is supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
includes()
is not supported in internet Explorer or Edge 13 (or earlier).
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!