jshint/jshint

undeclared variable in es6 comprehension

Open

#1,656 opened on May 4, 2014

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

Repository metrics

Stars
 (8,937 stars)
PR merge metrics
 (No merged PRs in 30d)

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