While diving into Eloquent JS, I stumbled upon this code snippet that left me puzzled. The explanation given didn't quite click with me, so I'm reaching out for some clarification on why the second console.log
returns the value it does.
Take a look at the code below:
var listOfNumbers = [2, 3, 5, 7, 11];
console.log(listOfNumbers[1]);
// → 3
console.log(listOfNumbers[1 - 1]);
// → 2
Any thoughts on this?