jshint/jshint

undeclared variable in es6 comprehension

Open

#1656 opened on May 4, 2014

View on GitHub
 (4 comments) (0 reactions) (0 assignees)JavaScript (8,937 stars) (1,757 forks)batch import
P4help wantedmoz

Description

[for (i of [1,2,3]) i]

Jshint will warn that i is undeclared. Should it? This makes the warning go away:

var i;
[for (i of [1,2,3]) i]

but seems dubious. For example, in the traceur-generated code, the two "i"s are different "i"s. The "i" in the comprehension is scoped to the comprehension.

Contributor guide