首页 > 解决方案 > 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);

标签: javascriptarraysindexing

解决方案


您只需要像这样访问它:

myArray[myIndex]

推荐阅读