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

Prepare for the TJR Bootcamp Test with quizzes and flashcards. Each question includes hints and explanations to boost your readiness for the exam!

Multiple Choice

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

Understanding how JavaScript binds variables hinges on scope and mutability. Var is scoped to the containing function (or global if outside any function) and can be redeclared within that scope, which is why you can have multiple var declarations in the same function and they all refer to the same binding. Let and const introduce block scope, meaning their bindings exist only inside the nearest set of braces. Let allows reassignment, so you can change its value; const does not allow reassignment of the binding after it’s initialized. However, if the value is an object or array, you can still modify its contents; you just can’t replace the binding with a new object or array.

This combination—var being function-scoped and redeclarable; let and const being block-scoped, with let being mutable and const binding being read-only for reassignment—matches how these declarations actually behave, so it’s the correct description.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy