javascript - 如果值包含,如何获取数组中键的索引?
问题描述
这就是我的意思。
var brands = [['brand: LV'], ['brand: Apple']]...
有了这个,我想定位(索引)say..Apple。手动,我可以轻松做到
brands[1]
但这会动态更新,因此索引将是随机的。
解决方案
示例:brands.findIndex(doc => doc[0] === 'brand: Apple')
。
推荐阅读
- delphi-10.2-tokyo - 如何检查 TIdTCPClient 中的连接失效并进行处理?
- python - 每当我尝试在 VPS 上使用我的 Discord 机器人登录时,都会出现“SSL:Certificate_verify_failed”
- java - 将对象列表转换为属性映射
- java - Java Matcher.group(int) 显示以前的匹配值
- android - 如何在适配器中处理 onPause 和 onResume?
- c++ - 为什么这个总工资函数返回 0?
- javascript - 何时移除组件中的骨架屏幕?
- java - 无法在 android 中获取广告 ID 提供者
- java - 使用用户输入创建 2 个维度数组并查找特定列的总和
- ios - 如何在 iOS Swift 中剪切部分 CALayer?