On the scope of for cycle

var inputs= [254.63pm 5863J.96];

for (let iBoth I < 2th Ipp) {
const x=inputs [0];
const y=inputs [1];
var bouncy;

}

ask whether the for loop let defines the I value so that all variables in the for loop are in block-level scope

is like the var used by the variable b to define whether it can be accessed outside the for loop

and if you define b outside the for loop first, can you get the value outside the for loop by defining the value inside the for?

Mar.16,2022

first of all, I suggest you sort out the description of your problem. Secondly, for these basic grammar questions or if you want to know the knowledge of ES6, you can go to introduction to es6 written by teacher Ruan Yifeng. There is no need to ask questions that you can get through your own search. No, no, no.

answer:

  1. counter I is only valid in for circulation, and an error will be reported if it is quoted outside the circulation.
  2. var has no block-level scope.
  3. the last question can be found out by opening the console and giving it a try.

the value declared outside cannot be declared with const or let , but cannot be accessed after for loop.
but there is no problem with assigning values.

Menu