2

say I have some kind of function range which creates an array from min to max, like range(4,10). Say I want to loop through this array with a for-in loop like so:

for(i in range(4,10)) console.log(i);

If you try something like this out, you will notice that i starts from 0, not from 4. Is there a simple way (I guess without just adding the minimal ammount and without storing "range(4,10)" in a variable) to access the current value that is being looped through in the array? I believe in C# the syntax would be something like i.Key, does a similar property exist in the i variable? Or is there some kind of keyword that the value to the right of "in" is stored in within that scope that can be used for indexing?

0 Answers0