W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JavaScript Array.every()</h1> <p>every() 方法检查所有数组值是否通过测试。</p> <p id="demo"></p> <script> var numbers = [45, 4, 9, 16, 25]; var allOver18 = numbers.every(myFunction); document.getElementById("demo").innerHTML = "All over 18 is " + allOver18; function myFunction(value, index, array) { return value > 18; } </script> </body> </html>