The responses above are accurate in stating that you can use .findIndex()
to retrieve the index and .find()
to get the actual entry from the array.
However, it appears that you are questioning how to obtain both the index and the entry simultaneously from the array.
If my assumption is correct, you may consider trying the following approach:
let array = ["Sunday", "Monday", "Tuesday", "Wednesday", "Friday", "Saturday"];
let tuesday = array.map((day,index) => {
if(day == "Tuesday")
return {day, index}
}).filter(day => day)[0];
console.log(tuesday);
Upon executing this code, you should receive an object containing both the entry and the index in this format:
{"day": "Tuesday", "index": 2}
While this method may not be the most efficient way to retrieve both values simultaneously, it does achieve the desired outcome.