运行 ❯
获取您的
自己
网站
×
更改方向
保存代码
更改主题,暗/亮
转到 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <h2>The find() Method</h2> <p>find() returns the value of the first element in an array that passes a test (provided by a function):</p> <p id="demo"></p> <script> const ages = [3, 10, 18, 20]; document.getElementById("demo").innerHTML = ages.find(checkAge); function checkAge(age) { return age > 18; } </script> <p>The find() method is not supported in Internet Explorer.</p> </body> </html>