Learn. Practice. Feel prepared.
JavaScript Objective Questions and Answers - Set 4
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. This is part 4 of the series.
Practice JavaScript MCQs with Detailed Explanations
Answer at least 12 questions to submit and verify answers.
46 What does setTimeout(fn, 0) guarantee? High
Correct answer:
Execution after current call stack
setTimeout schedules execution after the current stack completes.
47 Which is NOT a primitive type? Medium
Correct answer:
object
Objects are non-primitive reference types.
48 What will be logged? console.log(typeof []); Medium
Correct answer:
object
Arrays are objects in JavaScript.
49 Which scenario causes callback hell? Medium
Correct answer:
Deeply nested async callbacks
Deep nesting of callbacks reduces readability and maintainability.
50 What is the output? console.log('5' - 2); Medium
Correct answer:
3
String is coerced to number for subtraction.
51 Which causes implicit type coercion? Medium
Correct answer:
==
Loose equality performs implicit type coercion.
52 What will be logged? console.log(Promise.resolve() === Promise.resolve()); High
Correct answer:
false
Each Promise is a distinct object.
53 Which avoids blocking the UI thread? High
Correct answer:
Web Workers
Web Workers run in separate threads.
54 What happens when an exception is thrown inside async? High
Correct answer:
Promise rejects
Thrown errors reject the returned Promise.
55 Which prevents prototype pollution? High
Correct answer:
Object.create(null)
Objects without prototypes avoid inherited pollution.
56 What will be logged? console.log(typeof class A {}); Medium
Correct answer:
function
Classes are syntactic sugar over functions.
57 Which pattern reduces memory usage? High
Correct answer:
Singleton
Singleton ensures only one instance exists.
58 What is the output? console.log(+''); Medium
Correct answer:
0
Empty string is coerced to 0.
59 Which structure allows garbage collection of keys? High
Correct answer:
WeakMap
WeakMap keys are weakly referenced.
60 Why should deep cloning be handled carefully in JavaScript? High
Correct answer:
Circular references can cause errors
Deep cloning can fail or cause infinite recursion when circular references exist.