for in ts 1

for in ts

for (let entry of someArray) {
  console.log(entry); // 1, "string", false
}

var numbers = [1, 2, 3];
for (var _i = 0; _i < numbers.length; _i++) {
  var num = numbers[_i];
  console.log(num);
}

Here is what the above code is Doing:
1. The first line declares a variable called numbers and assigns it an array of numbers.
2. The second line declares a variable called _i and assigns it the value of 0.
3. The third line declares a variable called num and assigns it the value of numbers[0].
4. The fourth line logs the value of num to the console.
5. The fifth line increments the value of _i by 1.
6. The sixth line checks to see if _i is less than the length of numbers.
7. If it is, the loop runs again. If it isn't, the loop stops.

Similar Posts