Vidyalelo
JavaScript · Q50

Classes And Modules

Programming · JavaScript · question 50

Q50

The let keyword can be used

A.
in a for or for/in loop, as a substitute for var
B.
as a block statement, to define new variables
C.
to define variables that are scoped to a single expression
D.
all of the mentioned
Answer

Answer: Option D

Solution

Answer: Option D
Solution:
The let keyword can be used in four ways :
1. as a variable declaration like var;
2. in a for or for/in loop, as a substitute for var;
3. as a block statement, to define new variables and explicitly delimit their scope; and
4. to define variables that are scoped to a single expression.