javascript - Javascript - Find Value of Item in Array by Knowing Index
问题描述
I have a JavaScript array:
var myArray = [linkA, linkB, linkC, linkD, linkE, linkF, linkG, linkH, linkI, linkJ];
I know the value of the index from other calculations. So what I want to do is find an item in the array based on the known index value. Here's what I've tried so far but it's not working:
var myIndex = 1; //Set from other calculations
var myIndexValue = myArray.find(myIndex);
解决方案
您只需要像这样访问它:
myArray[myIndex]
推荐阅读
- reactjs - 我想通过 puppeteer 传递一组数据来呈现 react-vis 组件,而不是在 html 模板中传递数据?
- javascript - 获取错误消息原因 get addrinfo ENOTFOUND localhost
- sorting - 使用 frama-c 的递归快速排序的正式证明
- wcf - 增加 WCF 服务终结点大小配置的问题
- python - SimpleCookie 泛型类型
- java - 将配置传递给 Kafka 客户端的推荐方法
- typescript - 打字稿对象值扩展类型
- authorization - ActivePivot 授权
- python - vscode 运行所有测试(pytest)失败
- oracle - 2个符号oracle之间的相似性