gpt4 book ai didi

JavaScript:查找值是否在数组中的对象内的最佳方法

转载 作者:数据小太阳 更新时间:2023-10-29 05:47:08 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Find object by id in an array of JavaScript objects
How to check if value exists in this JavaScript array?

例如:

var arr = [
{id: 1, color: 'blue'},
{id: 2, color: 'red'},
{id: 3, color: 'yellow'}
];

alert( indexOf('blue') ); // How can I get the index of blue??

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com