HomeSubjectsUniversityBlogAbout

Advanced JavaScript

Topic in Web Development

210 total MCQsShowing 30 with explanations10 Easy10 Medium10 Hard

About This Topic

Asynchronous JavaScript is the use of callbacks, Promises and async/await to run slow operations without blocking the main thread. Many questions ask you to predict output order by reasoning about the event loop, the call stack, and the difference between the microtask queue (Promise callbacks) and the macrotask queue (setTimeout). Know Promise.all, allSettled, race and any, and error handling with try/catch around await. Other advanced areas include prototypal inheritance and ES6 classes, how this is bound by call, apply and bind, generators and iterators, destructuring, spread and rest syntax, modules, Proxy and Reflect, and garbage collection.

Below are 30 practice questions from a pool of 210 Advanced JavaScript MCQs, one of 17 topics in Web Development. Each shows the correct answer with an explanation; when you are ready, take a timed quiz to test recall under exam conditions.

Practice Questions

Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.

Advanced JavaScriptEasy

Q1. What is a Promise in JavaScript?

  1. A.A looping construct for iterating over arrays
  2. B.A type of variable for storing constant values
  3. C.A guarantee of optimal performance metrics
  4. D.An object representing an async operation result✓ Correct

Explanation

A Promise represents an asynchronous operation that will eventually resolve or reject.

Report an error in this question

Advanced JavaScriptEasy

Q2. What keyword makes a function asynchronous?

  1. A.defer
  2. B.await
  3. C.promise
  4. D.async✓ Correct

Explanation

The async keyword makes a function return a Promise.

Report an error in this question

Advanced JavaScriptEasy

Q3. What does the await keyword do?

  1. A.Stops the program from running permanently
  2. B.Pauses async execution until a Promise settles✓ Correct
  3. C.Creates a timed delay between code statements
  4. D.Waits for CSS stylesheets to fully load

Explanation

await pauses async function execution until the Promise resolves.

Report an error in this question

Advanced JavaScriptEasy

Q4. What is the spread operator in JavaScript?

  1. A.The ... operator expanding iterables into elements✓ Correct
  2. B.The => operator for defining arrow function bodies
  3. C.The ** operator for exponentiation calculations
  4. D.The -> operator for creating arrow function syntax

Explanation

The spread operator (...) expands arrays, objects, or strings into individual elements.

Report an error in this question

Advanced JavaScriptEasy

Q5. What is an arrow function?

  1. A.A function that draws arrow graphics on canvas
  2. B.A built-in math function for calculations
  3. C.A recursive function that calls itself repeatedly
  4. D.A shorter syntax for writing functions using =>✓ Correct

Explanation

Arrow functions provide a concise syntax and do not have their own this binding.

Report an error in this question

Advanced JavaScriptEasy

Q6. What does fetch() do in JavaScript?

  1. A.Makes HTTP requests to retrieve network resources✓ Correct
  2. B.Downloads files directly to the local disk
  3. C.Imports CSS files into a JavaScript module
  4. D.Fetches DOM elements by their CSS selectors

Explanation

fetch() provides a modern way to make HTTP requests and returns a Promise.

Report an error in this question

Advanced JavaScriptEasy

Q7. What is a JavaScript module?

  1. A.A debugging tool for inspecting runtime state
  2. B.A browser plugin for extending functionality
  3. C.A testing framework for unit test execution
  4. D.A file that exports and imports reusable code✓ Correct

Explanation

Modules allow code to be organized into separate files that export and import code.

Report an error in this question

Advanced JavaScriptEasy

Q8. Which keyword is used to export from a module?

  1. A.output
  2. B.export✓ Correct
  3. C.module
  4. D.send

Explanation

The export keyword makes functions, objects, or values available for import.

Report an error in this question

Advanced JavaScriptEasy

Q9. What is the rest parameter in JavaScript?

  1. A.A sleep function that pauses code execution
  2. B.Syntax (...args) collecting remaining arguments✓ Correct
  3. C.A default parameter value for function calls
  4. D.A parameter specifically for REST API calls

Explanation

The rest parameter (...args) collects all remaining function arguments into an array.

Report an error in this question

Advanced JavaScriptEasy

Q10. What is try...catch used for?

  1. A.Testing CSS styles in the browser
  2. B.Importing modules from external files
  3. C.Handling errors and exceptions in code✓ Correct
  4. D.Creating loops that iterate over data

Explanation

try...catch handles runtime errors by catching exceptions.

Report an error in this question

Advanced JavaScriptMedium

Q11. What is Promise.all() used for?

  1. A.Running multiple promises and waiting for all✓ Correct
  2. B.Creating a sequential promise chain
  3. C.Resolving only a single individual promise
  4. D.Canceling all pending promises at once

Explanation

Promise.all() returns a single promise that resolves when all input promises resolve.

Report an error in this question

Advanced JavaScriptMedium

Q12. What is the difference between Promise.all() and Promise.allSettled()?

  1. A.Promise.allSettled() also fails immediately on rejection
  2. B.Promise.all() is always slower in execution speed
  3. C.Promise.all() fails on rejection; allSettled() waits for all✓ Correct
  4. D.They are identical in their behavior

Explanation

Promise.all() short-circuits on rejection, while Promise.allSettled() waits for all to settle.

Report an error in this question

Advanced JavaScriptMedium

Q13. What is optional chaining (?.) in JavaScript?

  1. A.Safely accesses nested properties without errors✓ Correct
  2. B.A ternary operator for conditional expressions
  3. C.A loop syntax for iterating over object entries
  4. D.A regex operator for pattern matching in strings

Explanation

Optional chaining returns undefined instead of throwing when accessing properties of null or undefined.

Report an error in this question

Advanced JavaScriptMedium

Q14. What is the nullish coalescing operator (??)?

  1. A.A ternary for inline conditional expressions
  2. B.Returns right operand when left is null/undefined✓ Correct
  3. C.A logical OR for boolean expressions
  4. D.A strict equality check comparing type and value

Explanation

?? returns the right operand only when the left is null or undefined.

Report an error in this question

Advanced JavaScriptMedium

Q15. What is a Proxy in JavaScript?

  1. A.A web proxy server for routing network traffic
  2. B.An object wrapping another to intercept operations✓ Correct
  3. C.A network library for making HTTP request calls
  4. D.A design pattern used only in OOP code contexts

Explanation

A Proxy wraps an object and lets you define custom behavior for fundamental operations.

Report an error in this question

Advanced JavaScriptMedium

Q16. What is the purpose of Object.entries()?

  1. A.To merge multiple objects into a combined one
  2. B.To return an array of [key, value] pairs✓ Correct
  3. C.To create new entries within an object literal
  4. D.To check if a specific object reference exists

Explanation

Object.entries() returns an array of [key, value] pairs from an object.

Report an error in this question

Advanced JavaScriptMedium

Q17. What is a Set in JavaScript?

  1. A.A type of map for key-value pair storage
  2. B.An array method for modifying element order
  3. C.A function to set values on object properties
  4. D.A collection of unique values with no duplicates✓ Correct

Explanation

A Set stores unique values of any type, automatically removing duplicates.

Report an error in this question

Advanced JavaScriptMedium

Q18. What is dynamic import in JavaScript?

  1. A.Using import() to load modules on demand at runtime✓ Correct
  2. B.Importing CSS styles dynamically at runtime
  3. C.Importing all application modules simultaneously
  4. D.A feature exclusive to the Webpack bundler tool

Explanation

Dynamic import() loads modules on demand, enabling code splitting.

Report an error in this question

Advanced JavaScriptMedium

Q19. What is the for...of loop used for?

  1. A.Iterating over the keys of an object
  2. B.Executing queries against a database
  3. C.A C-style for loop with index counters
  4. D.Iterating over values of iterable objects✓ Correct

Explanation

for...of iterates over the values of iterable objects.

Report an error in this question

Advanced JavaScriptMedium

Q20. What does Object.assign() do?

  1. A.Compares two objects for deep structural equality
  2. B.Assigns type annotations to JavaScript objects
  3. C.Creates a deep copy of all nested objects
  4. D.Copies enumerable own properties to a target (shallow)✓ Correct

Explanation

Object.assign() performs a shallow copy of properties from source to target objects.

Report an error in this question

Advanced JavaScriptHard

Q21. What is the difference between microtasks and macrotasks?

  1. A.Microtasks run on a separate background thread
  2. B.Macrotasks always have higher execution priority
  3. C.They are identical in execution priority
  4. D.Microtasks execute before macrotasks in the loop✓ Correct

Explanation

Microtasks are processed before the next macrotask in each event loop iteration.

Report an error in this question

Advanced JavaScriptHard

Q22. What is a SharedArrayBuffer?

  1. A.A binary data buffer shared between workers✓ Correct
  2. B.A database buffer for caching query results
  3. C.A shared CSS buffer for component styling
  4. D.An array with elements shared across files

Explanation

SharedArrayBuffer allows sharing memory between the main thread and web workers.

Report an error in this question

Advanced JavaScriptHard

Q23. What is the Reflect API in JavaScript?

  1. A.A browser debugging tool for inspecting elements
  2. B.A library for creating mirror image visual effects
  3. C.A CSS reflection API for reflecting element visuals
  4. D.A built-in object with interceptable operation methods✓ Correct

Explanation

Reflect provides static methods matching Proxy trap operations.

Report an error in this question

Advanced JavaScriptHard

Q24. What is structural typing in TypeScript?

  1. A.TypeScript uses nominal typing with explicit declarations
  2. B.JavaScript has stronger typing than TypeScript overall
  3. C.They use the identical type system without differences
  4. D.TypeScript checks compatibility based on type structure✓ Correct

Explanation

TypeScript uses structural typing where compatibility is determined by the shape of data.

Report an error in this question

Advanced JavaScriptHard

Q25. What is the AbortController API?

  1. A.A process manager for handling background server tasks
  2. B.An error handling mechanism for catching thrown errors
  3. C.An API to cancel fetch requests and async operations✓ Correct
  4. D.A method to stop all JavaScript execution immediately

Explanation

AbortController provides a signal to cancel ongoing asynchronous operations.

Report an error in this question

Advanced JavaScriptHard

Q26. What are Decorators in JavaScript/TypeScript?

  1. A.Functions that modify classes and members via @ syntax✓ Correct
  2. B.String formatting tools for template processing
  3. C.CSS decorations like border styles and shadows
  4. D.HTML attributes added to elements for metadata

Explanation

Decorators are special functions prefixed with @ that modify class declarations and members.

Report an error in this question

Advanced JavaScriptHard

Q27. What is the structuredClone() function?

  1. A.A function creating deep copies via structured clone✓ Correct
  2. B.A CSS cloning function for duplicating style rules
  3. C.A function to clone the DOM structure of elements
  4. D.A shallow copy method copying only top-level values

Explanation

structuredClone() creates a deep copy handling nested structures and circular references.

Report an error in this question

Advanced JavaScriptHard

Q28. What is the difference between for...in and for...of?

  1. A.for...in only works with arrays not objects
  2. B.for...of iterates over property keys of objects
  3. C.They are identical in their iteration behavior
  4. D.for...in iterates keys; for...of iterates values✓ Correct

Explanation

for...in loops over property names, while for...of loops over values of iterables.

Report an error in this question

Advanced JavaScriptHard

Q29. What is a FinalizationRegistry in JavaScript?

  1. A.An API to register a callback when an object is GC'd✓ Correct
  2. B.A module registry for tracking installed packages
  3. C.A service worker registry for managing active workers
  4. D.A software design pattern for object creation

Explanation

FinalizationRegistry registers cleanup callbacks that execute when objects are garbage collected.

Report an error in this question

Advanced JavaScriptHard

Q30. What is the Intl object in JavaScript?

  1. A.An interface definition for declaring TypeScript contracts
  2. B.An interval timer for scheduling repeated function calls
  3. C.An internal object for private variable storage
  4. D.A namespace for Internationalization with locale formatting✓ Correct

Explanation

Intl provides constructors for locale-sensitive formatting of strings, numbers, and dates.

Report an error in this question

Ready to test yourself on Advanced JavaScript?

Take a timed quiz drawn from 210+ questions on this topic. No signup required — your progress saves in your browser.

Start Advanced JavaScript Quiz