1. Home
  2. Computer Science MCQs
  3. Javascript
  4. A variable declared with let in JavaScript is:

Added 2 Nov 2026

A variable declared with let in JavaScript is:

  1. Scoped to the whole enclosing function
  2. Scoped to the nearest enclosing block Correct answer
  3. Always attached to the global object
  4. Hoisted and initialised as undefined

Correct answer

B. Scoped to the nearest enclosing block

15 views

MCQSEXAM

Explanation

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.

Reference

Asked in: Frontend Developer Tests, Technical Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Javascript MCQs

Practise all Javascript MCQs

Similar MCQs