How does hoisting affect variable shadowing in JavaScript?
A). A. It allows variables with the same name in different scopes to coexist
B). B. It prevents variables with the same name in different scopes from coexisting
C). C. It has no effect on variable shadowing
D). D. It automatically renames variables with the same name
How does hoisting affect function declarations in JavaScript?
A). A. Function declarations are hoisted with their function bodies
B). B. Function declarations are hoisted but cannot be accessed before declaration
C). C. Function declarations are not hoisted
D). D. Hoisting has no effect on function declarations
What happens if you declare a const variable with the same name as an existing variable in JavaScript?
A). A. SyntaxError is thrown
B). B. The existing variable is reassigned
C). C. ReferenceError is thrown
D). D. TypeError is thrown
What happens if you access a var variable before its declaration in JavaScript?
A). A. ReferenceError
B). B. TypeError
C). C. undefined
D). D. No error
How can you ensure that a const variable is initialized before use in JavaScript?
A). A. Use let instead of const for all variables
B). B. Declare const variables at the top of their scope
C). C. Assign a default value to const variables
D). D. None of the above
What is the output of the following code snippet?
A). A. TypeError
B). B. 10
C). C. undefined
D). D. SyntaxError
How does hoisting differ between let and var declarations in JavaScript?
A). A. Both let and var variables are hoisted with their initial values
B). B. let variables are hoisted with their initial values, var variables are hoisted with undefined
C). C. let variables are not hoisted, var variables are hoisted with their initial values
D). D. Hoisting behavior is the same for let and var declarations
Which of the following is true about const variables in JavaScript?
A). A. They can be reassigned after declaration
B). B. They can be accessed before declaration
C). C. They cannot be declared without an initial value
D). D. They cannot be hoisted
What is the behavior of accessing a const variable within a function before its declaration in JavaScript?
A). A. ReferenceError is thrown
B). B. SyntaxError is thrown
C). C. undefined is printed
D). D. No error
Which keyword allows hoisting of variables in JavaScript?
A). A. var
B). B. let
C). C. const
D). D. Both A and B