W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JavaScript Array.findIndex()</h1> <p id="demo"></p> <script> var numbers = [4, 9, 16, 25, 29]; var first = numbers.findIndex(myFunction); document.getElementById("demo").innerHTML = "大于 18 的第一个值的索引是:" + first; function myFunction(value, index, array) { return value > 18; } </script> </body> </html>