CodeLab
Show Output
 
xxxxxxxxxx
17
 
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
    <meta charset="utf-8">
5
    <title>JavaScript Find Whether an Array Includes a Certain Value</title>
6
</head>
7
<body>
8
    <script>
9
    var arr = [1, 0, 3, 1, false, 5, 1, 4, 7];
10
 
11
    document.write(arr.includes(1) + "<br>"); // Prints: true
12
    document.write(arr.includes(6) + "<br>"); // Prints: false
13
    document.write(arr.includes(1, 2) + "<br>"); // Prints: true
14
    document.write(arr.includes(3, 4)); // Prints: false
15
    </script>
16
</body>
17
</html>
 

在微博、微信、公众号、小程序分享此示例。 如果您觉得有帮助,请给我们一个赞。