Which keyword is used to declare a block-scoped variable in JavaScript?
A
var B
let C
const D
int
Analysis & Theory
`let` is used to declare block-scoped variables.
Which keyword declares a constant variable that cannot be reassigned?
A
let B
const C
var D
final
Analysis & Theory
`const` is used for variables that cannot be reassigned.
Which of the following is NOT a valid variable name in JavaScript?
A
_count B
2value C
value2 D
$money
Analysis & Theory
Variable names cannot start with a digit like `2value`.
What will happen if you declare a variable using `let` and then declare it again in the same scope?
A
It will override the previous value B
It will create a new variable C
It will cause a SyntaxError D
It will be ignored
Analysis & Theory
Re-declaring a `let` variable in the same scope causes a SyntaxError.
What is the default value of an uninitialized variable in JavaScript?
A
null B
undefined C
0 D
false
Analysis & Theory
Uninitialized variables are `undefined` by default.
Which of the following correctly declares a variable and assigns a string value?
A
let name = 'John'; B
var = 'John'; C
string name = John; D
const name == 'John';
Analysis & Theory
`let name = 'John';` is correct syntax for declaring a variable with a string value.
Can you reassign a variable declared with `const`?
A
Yes, anytime B
Only inside a function C
No, it's a constant D
Only if it's a number
Analysis & Theory
`const` variables cannot be reassigned after declaration.
Which symbol is used for assignment in JavaScript?
A
== B
= C
=== D
:=
Analysis & Theory
`=` is the assignment operator in JavaScript.
What is the scope of a variable declared using `var` inside a function?
A
Global B
Block C
Function D
Module
Analysis & Theory
`var` is function-scoped, not block-scoped.
Which keyword was introduced in ES6 to fix scoping issues with `var`?
A
static B
int C
let D
define
Analysis & Theory
`let` was introduced in ES6 to provide block-level scoping.