Salesforce JavaScript Developer Practice Exam 2025 – 400 Free Practice Questions to Pass the Exam

Image Description

Question: 1 / 400

What will be the output of console.log(x); let x = 10;?

10

undefined

ReferenceError

When you attempt to log the value of `x` to the console before it has been initialized, you will encounter a `ReferenceError`. This occurs because `let` declarations are block-scoped and are not hoisted in the same way that `var` declarations are. While `var` would allow you to access the variable and receive `undefined`, `let` does not allow access to the variable until the declaration has been encountered in the code.

In this case, `console.log(x)` is executed before the line `let x = 10;` is reached, leading to a situation where `x` remains uninitialized and unreferenced. As a result, JavaScript raises a `ReferenceError`, indicating that `x` is not defined at the point of the console log. This behavior is part of the temporal dead zone concept in JavaScript, which prevents access to variables before they are declared.

Get further explanation with Examzify DeepDiveBeta

NaN

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy