HLJ 发布于
2018-08-12 17:52:19

JavaScript 根据对象某属性获得其在数组中的index

JavaScript 根据对象某属性获得其在数组中的index
示例代码:
<script type="text/javascript">
    var arr = new Array({"name": "wxx", "age": 2}, {"name": "wyw", "age": 6});

    var index = arr.findIndex(function(item) {
        return item.name === "wyw";
    });
    console.log(index);
</script>
输出结果:
1
当前文章内容为原创转载请注明出处:http://www.good1230.com/detail/2018-08-12/79.html
最后生成于 2024-05-27 22:52:48
此内容有帮助 ?
0