源代码:
下载代码
AI 编程工具
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> </head> <body> <h1>JavaScript 数组</h1> <h2>findLastIndex()</h2> <p>findLastIndex() 返回通过验证(由函数提供)的最后一个元素的索引。</p> <p id="demo"></p> <script> const ages = [3, 10, 18, 20]; document.getElementById("demo").innerHTML = ages.findLastIndex(checkAge); function checkAge(age) { return age > 18; } </script> <p>Internet Explorer 不支持 findLastIndex() 方法。</p> </body> </html>
运行结果: