代码示例:(标识:jsck_find_2)
<!DOCTYPE html>
<html>
<body>

<h1>JavaScript 数组</h1>

<p>单击按钮可返回数组中第一个值高于此数字的元素的值:</p>

<p><input type="number" id="ageToCheck" value="18"></p>

<button onclick="myFunction()">试一试</button>

<p id="demo"></p>

<script>
const ages = [4, 12, 16, 20];

function checkAge(age) {
  return age > document.getElementById("ageToCheck").value;
}

function myFunction() {
  document.getElementById("demo").innerHTML = ages.find(checkAge);
}
</script>

<p>Internet Explorer 不支持 Array.find() 方法。</p>

</body>
</html>
运行结果: