How to How to get the index from for-of loop with JavaScript In this tutorial I will show you two ways that you can get the index when using a for-of loop. Let's start with the data that I will be using: const shoppingList = [ 'bread', 'milk', 'pie', 'juice' ] Option 1: .keys() The