<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>find方法</title>
</head>
<body>

</body>
<script>
    let arr = [
        {
            id:1,
            name:'zhangsan'
        },
        {
            id:2,
            name:'lisi'
        }
    ];

    //find方法用于查找第一个符合条件的数组成员,如果没有找到返回undefind
    let target = arr.find((item,index) => {
        return item.id ==1
    })
    console.log(target)
</script>
</html>

运行结果

es6 find方法用于查找第一个符合条件的数组成员,如果没有找到返回undefind

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案