Question 26
In JavaScript, what is the difference between var, let, and const regarding scope?
Option B is correct. var is scoped to the enclosing function block. let and const (introduced in ES6) are scoped to the nearest enclosing block ({}).
In JavaScript, what is the difference between var, let, and const regarding scope?
Option B is correct. var is scoped to the enclosing function block. let and const (introduced in ES6) are scoped to the nearest enclosing block ({}).
What is the output of typeof null in JavaScript?
Option A is correct. typeof null evaluates to 'object'. This is a legacy quirk in JavaScript dating back to its first version where primitive null pointers were encoded with an object type tag.
What is the difference between == (abstract equality) and === (strict equality) in JavaScript?
Option C is correct. == performs implicit type conversion if operands are of different types. === requires both type and value to match strictly without coercion.
What is a Closure in JavaScript?
Option C is correct. A closure gives an inner function access to its outer function's scope variables even after the outer function has finished executing.
Which JavaScript Array method produces a new array by applying a callback function to every element of the source array?
Option B is correct. map() creates a new array populated with the results of calling a provided function on every element in the calling array. forEach() executes side-effects without returning a new array.