JS Interview
JS Interview
JavaScript Basics
1. What is JavaScript?
A lightweight, interpreted scripting language used to create dynamic content on
websites.
4. What is typeof?
A JavaScript operator that returns the type of a given variable or value.
3. Functions
1. What are the different types of functions in JavaScript?
Named, anonymous, arrow, IIFE (Immediately Invoked Function Expressions).
2. What is async/await?
Syntactic sugar for writing asynchronous code more synchronously.
7. DOM Manipulation
1. What is the DOM?
A programming interface for HTML and XML documents.
8. Error Handling
1. How do you handle errors in JavaScript?
Using try, catch, finally blocks or Promise.catch.
1. What is memoization?
Caching function results to optimize performance for repetitive calls with the same
input.
12. Events
1. What are event listeners?
Functions triggered when an event occurs, added with addEventListener.
2. What is throttling?
Limiting the execution of a function to once in a specified interval.
3. What are web workers?
JavaScript scripts that run in the background, separate from the main thread.
2. What is Promise.all()?
Resolves when all Promises in an array resolve or rejects if one fails.
3. What is Promise.race()?
Resolves or rejects as soon as the first Promise in an array resolves or rejects.
1. What is a ReferenceError?
An error raised when trying to access an undefined variable.
2. What is a TypeError?
An error caused by using a value in an invalid operation for its type.
1. What is localStorage?
A browser storage feature for key-value pairs with no expiration.
2. What is sessionStorage?
A storage feature that persists data only during a page session.
2. What is DOMContentLoaded?
An event fired when the initial HTML document is fully loaded and parsed.
1. What is Promise.any()?
Resolves when the first Promise is fulfilled, ignoring rejections.
1. What is CORS?
Cross-Origin Resource Sharing, a policy controlling resource sharing between
origins.
4. What is JSON?
A lightweight data format for storing and exchanging data, commonly used in APIs.
40. Interview-Specific
1. What is hoisting?
Variables and functions are moved to the top of their scope during compilation.
1. How do you implement a debounce function?
Use setTimeout to delay a function call until after the user stops triggering it.