Which statement about var, let, and const is true?

Prepare for the TJR Bootcamp Test with targeted questions and detailed explanations. Use mock exams to enhance understanding and boost your confidence. Gear up for success!

Multiple Choice

Which statement about var, let, and const is true?

Explanation:
Understanding how variable declarations behave with var, let, and const in JavaScript. The statement that let is block-scoped and can be reassigned is true. Block scope means the binding is only visible inside the nearest pair of curly braces, such as inside a function, loop, or conditional block. Because of this scope, a let variable is not accessible outside that block. It can be assigned a new value later, which is what “can be reassigned” expresses. At the same time, you cannot redeclare the same binding with let in the same scope, which helps prevent accidental redefinitions. Why the other points aren’t correct: var is not block-scoped; it’s function-scoped (or globally scoped if declared outside a function), and it can be redeclared in the same scope. Const is block-scoped like let but cannot be reassigned after its initial binding (though, for objects, the contents can still be mutated). And letting a binding be redeclared in the same scope with let is not allowed, which is why that statement is false.

Understanding how variable declarations behave with var, let, and const in JavaScript. The statement that let is block-scoped and can be reassigned is true. Block scope means the binding is only visible inside the nearest pair of curly braces, such as inside a function, loop, or conditional block. Because of this scope, a let variable is not accessible outside that block. It can be assigned a new value later, which is what “can be reassigned” expresses. At the same time, you cannot redeclare the same binding with let in the same scope, which helps prevent accidental redefinitions.

Why the other points aren’t correct: var is not block-scoped; it’s function-scoped (or globally scoped if declared outside a function), and it can be redeclared in the same scope. Const is block-scoped like let but cannot be reassigned after its initial binding (though, for objects, the contents can still be mutated). And letting a binding be redeclared in the same scope with let is not allowed, which is why that statement is false.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy