Learn. Practice. Feel prepared.
JavaScript Objective Questions and Answers
This JavaScript quiz contains carefully curated objective questions with correct answers and clear explanations. It is designed for frontend and backend developers, interview preparation, and deep understanding of modern JavaScript concepts including ES6+, asynchronous behavior, scope, closures, and performance pitfalls.
Practice JavaScript MCQs with Detailed Explanations
Answer at least 12 questions to submit and verify answers.
1 What will be the output of the following code? console.log(typeof null); Easy
Correct answer:
object
Due to a historical bug, typeof null returns 'object' in JavaScript.
2 What is the output? console.log(0.1 + 0.2 === 0.3); Easy
Correct answer:
false
Floating-point precision causes 0.1 + 0.2 to not equal exactly 0.3.
3 What will be logged? let x = 5; (function () { console.log(x); let x = 10; })(); Medium
Correct answer:
ReferenceError
Accessing a let variable before initialization results in a ReferenceError due to the temporal dead zone.
4 What is the output? console.log([] + []); Medium
Correct answer:
""
Both arrays are coerced to empty strings, resulting in an empty string.
5 Which statement about closures is correct? Medium
Correct answer:
Closures allow access to outer scope variables after execution
Closures preserve access to variables from their lexical scope even after the outer function finishes execution.
6 What will be the output? console.log(typeof NaN); Medium
Correct answer:
number
NaN is considered a number type in JavaScript.
7 What does Object.freeze() do? Medium
Correct answer:
Prevents any mutation of the object
Object.freeze makes an object immutable by preventing add, delete, or update operations.
8 What is the output? console.log([1, 2] == "1,2"); Medium
Correct answer:
true
The array is coerced into a string before comparison.
9 Which array method does NOT mutate the original array? Medium
Correct answer:
map()
map returns a new array without modifying the original one.
10 What will be printed? console.log(foo); var foo = 10; Medium
Correct answer:
undefined
var declarations are hoisted but initialized as undefined.
11 What is logged? console.log(!!"false"); Medium
Correct answer:
true
Non-empty strings are truthy, so double negation results in true.
12 Which keyword prevents reassignment but allows mutation? Medium
Correct answer:
const
const prevents reassignment of the variable but allows mutation of object contents.
13 What will be logged? console.log([] == ![]); High
Correct answer:
true
Type coercion converts both sides to numbers, resulting in equality.
14 Which mechanism enables asynchronous behavior in JavaScript? Medium
Correct answer:
Promises
Promises represent future completion or failure of asynchronous operations.
15 What does the following return? (() => { return arguments; })(); High
Correct answer:
ReferenceError
Arrow functions do not have their own arguments object.