HTML Diff
0 added 0 removed
Original 2026-01-01
Modified 2026-03-09
1 <p>Not only numbers can be written in square brackets. Any expression can be formatted this way. In the end, this expression will be converted to a number.</p>
1 <p>Not only numbers can be written in square brackets. Any expression can be formatted this way. In the end, this expression will be converted to a number.</p>
2 <p>Let’s practice this way of accessing array elements and alternate them with the same variable. To do this, you need to get a variable to store the current index of the array element. Let’s call it index and write the initial zero value in it.</p>
2 <p>Let’s practice this way of accessing array elements and alternate them with the same variable. To do this, you need to get a variable to store the current index of the array element. Let’s call it index and write the initial zero value in it.</p>
3 <p>If you now log the expression usersByDay[index] in the console, we’ll see the first value of the array. After all, now the variable holds zero, and the expression usersByDay[index] is equivalent to usersByDay[0].</p>
3 <p>If you now log the expression usersByDay[index] in the console, we’ll see the first value of the array. After all, now the variable holds zero, and the expression usersByDay[index] is equivalent to usersByDay[0].</p>
4 <p>If you change the value of the variable index from zero to one and access usersByDay[index] again, we’ll then get an element with the index 1, that is, the second element.</p>
4 <p>If you change the value of the variable index from zero to one and access usersByDay[index] again, we’ll then get an element with the index 1, that is, the second element.</p>
5 <p>Look, the expression in brackets in both cases is the same: usersByDay[index]. But it returns different values for different conditions.</p>
5 <p>Look, the expression in brackets in both cases is the same: usersByDay[index]. But it returns different values for different conditions.</p>
6 <p>If we continue to increase index and read elements of the array usersByDay, then sooner or later we will go through all the elements.</p>
6 <p>If we continue to increase index and read elements of the array usersByDay, then sooner or later we will go through all the elements.</p>