How does the scope of 'var' differ from 'let' and 'const' inside a function?
A). 'var' is block-scoped, 'let' and 'const' are function-scoped
B). 'var', 'let', and 'const' are all block-scoped
C). 'var' is function-scoped, 'let' and 'const' are block-scoped
D). 'var' and 'let' are block-scoped, 'const' is function-scoped
Which of the following correctly describes variable hoisting with 'var'?
A). 'var' declarations are not hoisted
B). Only the variable declaration is hoisted, not the initialization
C). Both declaration and initialization are hoisted
D). Only in strict mode 'var' declarations are hoisted
Which of the following correctly describes variable hoisting with 'let' and 'const'?
A). Both 'let' and 'const' declarations are not hoisted
B). Only 'let' declarations are hoisted
C). Only 'const' declarations are hoisted
D). Both 'let' and 'const' declarations are hoisted but not initialized
What will happen if you try to use a variable before declaring it with 'let'?
A). It will return undefined
B). It will return null
C). It will throw a ReferenceError
D). It will return NaN
What will happen if you declare a 'let' variable inside a block and try to access it outside the block?
A). It will return undefined
B). It will throw a ReferenceError
C). It will return null
D). It will be accessible outside the block
What is the result of redeclaring a variable with 'var' in the same scope in JavaScript?
A). Syntax Error
B). The variable is overwritten
C). The variable remains unchanged
D). The program crashes
Which of the following is a characteristic of 'const' variables?
A). They can be redeclared
B). They can be reassigned
C). They cannot be redeclared but can be reassigned
D). They cannot be redeclared or reassigned
Which of the following statements is true regarding redeclaring variables in JavaScript?
A). You can redeclare 'var' variables within the same scope without errors
B). You can redeclare 'let' variables within the same scope without errors
C). You can redeclare 'const' variables within the same scope without errors
D). None of the above
In which scenario would redeclaring a variable with 'var' lead to an unintended consequence?
A). When redeclaring in the same scope
B). When redeclaring in a different scope
C). When using 'strict mode'
D). When the variable has not been initialized
Can you redeclare a 'var' variable in a different scope without error?
A). Yes
B). No
C). Only in strict mode
D). Only if the variable is not initialized