A variable declared with let in JavaScript is:
Correct answer
B. Scoped to the nearest enclosing block
15 views
B. Scoped to the nearest enclosing block
15 views
let and const are block-scoped and sit in the temporal dead zone until declared. var is function-scoped and hoisted with the value undefined, which leads to bugs such as loop variables leaking.
Asked in: Frontend Developer Tests, Technical Interviews
Not sure why the answer is B? Ask here and get an explanation.