Johnston Johnston - 1 year ago 39
Javascript Question

Is this variable global in ES6?

Given the following abridged code (in ES6):

for (let i = 0, labelsLength = this.predefinedLabels.length; i < labelsLength; i++) {

being made into a global (
) variable?

Assuming this is the entire context you have.

Answer Source

It is not a global variable.

Mozilla Developer Network here states:

The let statement declares a block scope local variable, optionally initializing it to a value.


   let var1 [= value1] [, var2 [= value2]] [, ..., varN[= valueN]];

As you can see multiple declarations seperated by commas is fully supported.