XJavascript.com
Toggle Menu
Home
Online Javascript Compiler
Tutorials
JavaScript Tutorials
TypeScript Tutorials
Blog
All Posts
Advanced JavaScript Concepts
Challenge yourself with closures,prototypes,and asynchronous behavior.
1. What is a closure in JavaScript?
A function that has access to variables from its outer lexical scope even after the outer function has finished executing
A function that runs immediately when defined
A method attached to an object's prototype
A variable declared with 'let'
2. Which method is used to handle rejection in a Promise?
.catch()
.then()
.resolve()
.reject()
3. How is 'this' determined in an arrow function?
Lexical scope (inherited from the surrounding code)
Dynamic scope (depends on how the function is called)
Global object (window in browsers)
Undefined in strict mode
4. What is the primary role of the event loop in JavaScript?
Manages execution order, prioritizing synchronous tasks before asynchronous callbacks
Compiles JavaScript code into machine language
Optimizes memory usage in the JavaScript engine
Handles DOM events exclusively
5. What is the purpose of the prototype chain?
Enables inheritance by allowing objects to inherit properties from parent prototypes
Stores all global variables in a hierarchical structure
Defines the order of function execution in the call stack
Deep clones objects for immutability
6. Which keyword is used to declare a class in ES6?
class
function
object
prototype
7. Which are valid approaches to handle asynchronous operations in JavaScript?
Promises
async/await
Callbacks
setTimeout
8. Which statements about object destructuring are true?
Extracts multiple properties in a single line
Requires variable names to match object property names (without aliases)
Supports default values for missing properties
Cannot destructure nested objects
9. What are characteristics of ES6 modules?
Use 'import' and 'export' statements
Run in strict mode by default
Share variables globally with other modules
Are hoisted to the top of the file
10. Which built-in objects are iterable (support for...of loops)?
Array
Plain Object
Map
Set
11. Which methods create a shallow copy of an array?
slice()
spread operator ([...arr])
concat()
push()
12. Hoisting affects both variable declarations and function declarations.
True
False
13. In a regular global function, 'this' refers to the window object in browsers (non-strict mode).
True
False
14. Generator functions use the 'yield' keyword to pause and resume execution.
True
False
15. WeakMap keys can be primitive values like strings or numbers.
True
False
16. What is the abbreviation for Asynchronous JavaScript and XML?
17. What constructor creates a new Promise object (case-sensitive, starts with 'P')?
18. What keyword pauses a generator function and returns a value to the iterator?
19. What term describes a function that retains access to variables from its outer scope after the outer function exits?
20. What object defines custom behavior for operations like property lookup on another object?
Reset
Answered 0 of 0 — 0 correct