Master 193 curated questions covering the concepts most frequently tested at top companies — filtered by priority, topic, and difficulty.

193 of 193 questions
1

Describe event bubbling in JavaScript and browsers

high

Event bubbling is a DOM event propagation mechanism where an event (e.g. a click), starts at the target element and bubbles up to the root of the document. This allows...

medium5 min·GeneralFeaturedJavascriptHtml
2

Describe event capturing in JavaScript and browsers

high

Event capturing is a lesser-used counterpart to [event bubbling](/questions/quiz/describe-event-bubbling) in the DOM event propagation mechanism. It follows the opposit...

medium5 min·GeneralFeaturedJavascriptHtml
3

Describe the difference between `<script>`, `<script async>` and `<script defer>`

high

All of these ways (`<script>`, `<script async>`, and `<script defer>`) are used to load and execute JavaScript files in an HTML document, but they differ in how the bro...

medium5 min·GeneralFeaturedHtmlJavascript
4

Describe the difference between a cookie, `sessionStorage` and `localStorage` in browsers

high

All of the following are mechanisms of storing data on the client, the user's browser in this case. `localStorage` and `sessionStorage` both implement the [Web Storage...

medium5 min·GeneralFeaturedJavascript
5

Difference between: `function Person(){}`, `const person = Person()`, and `const person = new Person()` in JavaScript?

high

| Aspect | `function Person(){}` | `const person = Person()` | `const person = new Person()` | | --- | --- | --- | --- | | Type | Function declaration | Function call |...

medium5 min·GeneralFeaturedJavascript
6

Explain `Function.prototype.bind` in JavaScript

high

`Function.prototype.bind` is a method in JavaScript that allows you to create a new function with a specific `this` value and optional initial arguments. It's primary p...

medium5 min·GeneralFeaturedJavascript
7

Explain event delegation in JavaScript

high

Event delegation is a technique in JavaScript where a single event listener is attached to a parent element instead of attaching event listeners to multiple child eleme...

medium5 min·GeneralFeaturedJavascriptHtml
8

Explain how `this` works in JavaScript

high

There's no simple explanation for `this`; it is one of the most confusing concepts in JavaScript because it's behavior differs from many other programming languages. Th...

hard5 min·GeneralFeaturedJavascript
9

Explain how prototypal inheritance works in JavaScript

high

Prototypical inheritance in JavaScript is a way for objects to inherit properties and methods from other objects. Every JavaScript object has a special hidden property...

medium5 min·GeneralFeaturedJavascript
10

Explain the concept of "hoisting" in JavaScript

high

The following behavior summarizes the result of accessing the variables before they are declared.

hard5 min·GeneralFeaturedJavascript
11

Explain the difference between synchronous and asynchronous functions in JavaScript

high

Synchronous functions are blocking while asynchronous functions are not. In synchronous functions, statements complete before the next statement is run. As a result, pr...

medium5 min·GeneralFeaturedJavascript
12

Explain the differences on the usage of `foo` between `function foo() {}` and `var foo = function() {}` in JavaScript

high

`function foo() {}` a function declaration while the `var foo = function() {}` is a function expression. The key difference is that function declarations have its body...

medium5 min·GeneralFeaturedJavascript
13

What advantage is there for using the JavaScript arrow syntax for a method in a constructor?

high

The main advantage of using an arrow function as a method inside a constructor is that the value of `this` gets set at the time of the function creation and can't chang...

medium5 min·GeneralFeaturedJavascript
14

What are the differences between JavaScript ES2015 classes and ES5 function constructors?

high

ES2015 introduces a new way of creating classes, which provides a more intuitive and concise way to define and work with objects and inheritance compared to the ES5 fun...

hard5 min·GeneralFeaturedJavascript
15

What are the differences between JavaScript variables created using `let`, `var` or `const`?

high

In JavaScript, `let`, `var`, and `const` are all keywords used to declare variables, but they differ significantly in terms of scope, initialization rules, whether they...

medium5 min·GeneralFeaturedJavascript
16

What are the pros and cons of using Promises instead of callbacks in JavaScript?

high

Promises offer a cleaner alternative to callbacks, helping to avoid callback hell and making asynchronous code more readable. They facilitate writing sequential and par...

medium5 min·GeneralFeaturedJavascript
17

What are the various ways to create objects in JavaScript?

high

Creating objects in JavaScript offers several methods:

medium5 min·GeneralFeaturedJavascript
18

What is a closure in JavaScript, and how/why would you use one?

high

In the book ["You Don't Know JS"](https://github.com/getify/You-Dont-Know-JS/tree/2nd-ed/scope-closures) (YDKJS) by Kyle Simpson, a closure is defined as follows:

medium5 min·GeneralFeaturedJavascript
19

What is the definition of a higher-order function in JavaScript?

high

A higher-order function is any function that takes one or more functions as arguments, which it uses to operate on some data, and/or returns a function as a result.

medium5 min·GeneralFeaturedJavascript
20

What is the difference between `==` and `===` in JavaScript?

high

`==` is the abstract equality operator while `===` is the strict equality operator. The `==` operator will compare for equality after doing any necessary type conversio...

easy5 min·GeneralFeaturedJavascript
21

What is the event loop in JavaScript runtimes?

high

The event loop is concept within the browser runtime environment regarding how asynchronous operations are executed within JavaScript engines. It works as such:

hard5 min·GeneralFeaturedJavascript
22

What's a typical use case for anonymous functions in JavaScript?

high

Anonymous function in Javascript is a function that does not have any name associated with it. They are typically used as arguments to other functions or assigned to va...

medium5 min·GeneralFeaturedJavascript
23

What's the difference between `.call` and `.apply` in JavaScript?

high

`.call` and `.apply` are both used to invoke functions with a specific `this` context and arguments. The primary difference lies in how they accept arguments:

easy5 min·GeneralFeaturedJavascript
24

What's the difference between a JavaScript variable that is: `null`, `undefined` or undeclared?

high

| Trait | `null` | `undefined` | Undeclared | | --- | --- | --- | --- | | Meaning | Explicitly set by the developer to indicate that a variable has no value | Variable...

easy5 min·GeneralFeaturedJavascript
25

Can you offer a use case for the new arrow => function syntax?

medium

Arrow functions provide a concise syntax for writing functions in JavaScript. They are particularly useful for maintaining the `this` context within methods and callbac...

medium5 min·GeneralJavascript
26

Explain AJAX in as much detail as possible

medium

AJAX (Asynchronous JavaScript and XML) facilitates asynchronous communication between the client and server, enabling dynamic updates to web pages without reloading. It...

hard5 min·GeneralFeaturedJavascriptNetwork
27

Explain the difference between mutable and immutable objects in JavaScript

medium

**Mutable objects** allow for modification of properties and values after creation, which is the default behavior for most objects.

medium5 min·GeneralFeaturedJavascript
28

Explain the differences between CommonJS modules and ES modules in JavaScript

medium

In JavaScript, modules are reusable pieces of code that encapsulate functionality, making it easier to manage, maintain, and structure your applications. Modules allow...

hard5 min·GeneralFeaturedJavascript
29

Explain what a single page app is and how to make one SEO-friendly

medium

A single page application (SPA) is a web application that loads a single HTML page and dynamically updates content as the user interacts with the app. This approach pro...

hard5 min·GeneralJavascriptHtml
30

How do you abort a web request using `AbortController` in JavaScript?

medium

`AbortController` is used to cancel ongoing asynchronous operations like fetch requests.

hard5 min·GeneralFeaturedJavascriptNetwork
31

How does JavaScript garbage collection work?

medium

Garbage collection in JavaScript is an automatic memory management mechanism that reclaims memory occupied by objects and variables that are no longer in use by the pro...

hard5 min·GeneralFeaturedJavascript
32

What are `Symbol`s used for in JavaScript?

medium

`Symbol`s in JavaScript are a new primitive data type introduced in ES6 (ECMAScript 2015). They are unique and immutable identifiers that is primarily for object proper...

medium5 min·GeneralFeaturedJavascript
33

What are iterators and generators in JavaScript and what are they used for?

medium

In JavaScript, iterators and generators are powerful tools for managing sequences of data and controlling the flow of execution in a more flexible way.

hard5 min·GeneralFeaturedJavascript
34

What are JavaScript object getters and setters for?

medium

JavaScript object getters and setters are used to control access to an object's properties. They provide a way to encapsulate the implementation details of a property a...

medium5 min·GeneralFeaturedJavascript
35

What are JavaScript object property flags and descriptors?

medium

In JavaScript, property flags and descriptors manage the behavior and attributes of object properties.

medium5 min·GeneralFeaturedJavascript
36

What are JavaScript polyfills for?

medium

Polyfills in JavaScript are pieces of code that provide modern functionality to older browsers that lack native support for those features. They bridge the gap between...

medium5 min·GeneralFeaturedJavascript
37

What are server-sent events?

medium

[Server-sent events (SSE)](https://html.spec.whatwg.org/multipage/comms.html#the-eventsource-interface) is a standard that allows a web page to receive automatic update...

hard5 min·GeneralFeaturedJavascript
38

What are the advantages and disadvantages of using AJAX?

medium

AJAX (Asynchronous JavaScript and XML) is a technique in JavaScript that allows web pages to send and retrieve data asynchronously from servers without refreshing or re...

hard5 min·GeneralFeaturedJavascriptNetwork
39

What are the differences between `Map`/`Set` and `WeakMap`/`WeakSet` in JavaScript?

medium

The primary difference between `Map`/`Set` and `WeakMap`/`WeakSet` in JavaScript lies in how they handle keys. Here's a breakdown:

medium5 min·GeneralFeaturedJavascript
40

What are the differences between `XMLHttpRequest` and `fetch()` in JavaScript and browsers?

medium

`XMLHttpRequest` (XHR) and `fetch()` API are both used for asynchronous HTTP requests in JavaScript (AJAX). `fetch()` offers a cleaner syntax, promise-based approach, a...

hard5 min·GeneralFeaturedJavascriptNetwork
41

What are workers in JavaScript used for?

medium

Workers in JavaScript are background threads that allow you to run scripts in parallel with the main execution thread, without blocking or interfering with the user int...

medium5 min·GeneralFeaturedJavascript
42

What is `'use strict';` in JavaScript for?

medium

`'use strict'` is a statement used to enable strict mode to entire scripts or individual functions. Strict mode is a way to opt into a restricted variant of JavaScript.

hard5 min·GeneralFeaturedJavascript
43

What is the difference between a `Map` object and a plain object in JavaScript?

medium

Both `Map` objects and plain objects in JavaScript can store key-value pairs, but they have several key differences:

easy5 min·GeneralFeaturedJavascript
44

What's the difference between an "attribute" and a "property" in the DOM?

medium

Attributes are defined in the HTML and provide initial values for properties. Properties are part of the DOM and represent the current state of an element. For example,...

easy5 min·GeneralJavascriptHtml
45

Why is extending built-in JavaScript objects not a good idea?

medium

Extending a built-in/native JavaScript object means adding properties/functions to its `prototype`. While this may seem like a good idea at first, it is dangerous in pr...

medium5 min·GeneralFeaturedJavascript
46

Why is it, in general, a good idea to leave the global JavaScript scope of a website as-is and never touch it?

medium

JavaScript that is executed in the browser has access to the global scope (the `window` object). In general it's a good software engineering practice to not pollute the...

medium5 min·GeneralFeaturedJavascript
47

Why might you want to create static class members in JavaScript?

medium

Static class members (properties/methods) has a `static` keyword prepended. Such members cannot be directly accessed on instances of the class. Instead, they're accesse...

medium5 min·GeneralFeaturedJavascript
48

Difference between document `load` event and document `DOMContentLoaded` event?

low

The `DOMContentLoaded` event fires when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finis...

medium5 min·GeneralJavascriptHtml
49

Explain how JSONP works (and how it's not really Ajax)

low

JSONP (JSON with Padding) is a technique used to overcome the same-origin policy in web browsers, allowing you to request data from a server in a different domain. It w...

hard5 min·GeneralJavascriptNetworkSecurity
50

Explain the concept of `this` binding in event handlers

low

In JavaScript, the `this` keyword refers to the object that is currently executing the code. In event handlers, `this` typically refers to the element that triggered th...

easy5 min·This KeywordJavascript
51

Explain the concept of a callback function in asynchronous operations

low

A callback function is a function passed as an argument to another function, which is then invoked inside the outer function to complete some kind of routine or action....

easy5 min·Asynchronous JavaScriptJavascript
52

Explain the concept of a microtask queue

low

The microtask queue is a queue of tasks that need to be executed after the currently executing script and before any other task. Microtasks are typically used for tasks...

easy5 min·Asynchronous JavaScriptJavascript
53

Explain the concept of caching and how it can be used to improve performance

low

Caching is a technique used to store copies of files or data in a temporary storage location to reduce the time it takes to access them. It improves performance by redu...

easy5 min·Performance OptimizationJavascriptPerformance
54

Explain the concept of code coverage and how it can be used to assess test quality

low

Code coverage is a metric that measures the percentage of code that is executed when the test suite runs. It helps in assessing the quality of tests by identifying unte...

easy5 min·TestingJavascriptTesting
55

Explain the concept of Content Security Policy (CSP) and how it enhances security

low

Content Security Policy (CSP) is a security feature that helps prevent various types of attacks, such as Cross-Site Scripting (XSS) and data injection attacks, by speci...

easy5 min·SecurityJavascriptSecurity
56

Explain the concept of Cross-Site Request Forgery (CSRF) and its mitigation techniques

low

Cross-Site Request Forgery (CSRF) is an attack where a malicious website tricks a user's browser into making an unwanted request to another site where the user is authe...

easy5 min·SecurityJavascriptNetworkSecurity
57

Explain the concept of debouncing and throttling

low

Debouncing and throttling are techniques used to control the rate at which a function is executed. Debouncing ensures that a function is only called after a specified d...

easy5 min·Performance OptimizationJavascriptPerformance
58

Explain the concept of destructuring assignment for objects and arrays

low

Destructuring assignment is a syntax in JavaScript that allows you to unpack values from arrays or properties from objects into distinct variables. For arrays, you use...

easy5 min·Objects & ArraysJavascript
59

Explain the concept of error propagation in JavaScript

low

Error propagation in JavaScript refers to how errors are passed through the call stack. When an error occurs in a function, it can be caught and handled using `try...ca...

easy5 min·Error HandlingJavascript
60

Explain the concept of hoisting with regards to functions

low

Hoisting in JavaScript is a behavior where function declarations are moved to the top of their containing scope during the compile phase. This means you can call a func...

easy5 min·FunctionsJavascript
61

Explain the concept of inheritance in ES2015 classes

low

Inheritance in ES2015 classes allows one class to extend another, enabling the child class to inherit properties and methods from the parent class. This is done using t...

easy5 min·Prototypes & InheritanceJavascript
62

Explain the concept of input validation and its importance in security

low

Input validation is the process of ensuring that user input is correct, safe, and meets the application's requirements. It is crucial for security because it helps prev...

easy5 min·SecurityJavascriptSecurity
63

Explain the concept of lazy loading and how it can improve performance

low

Lazy loading is a design pattern that delays the loading of resources until they are actually needed. This can significantly improve performance by reducing initial loa...

easy5 min·Performance OptimizationJavascriptPerformance
64

Explain the concept of lexical scoping

low

Lexical scoping means that the scope of a variable is determined by its location within the source code, and nested functions have access to variables declared in their...

easy5 min·Closures & ScopeJavascript
65

Explain the concept of partial application

low

Partial application is a technique in functional programming where a function is applied to some of its arguments, producing a new function that takes the remaining arg...

easy5 min·Currying & Partial ApplicationJavascript
66

Explain the concept of scope in JavaScript

low

In JavaScript, scope determines the accessibility of variables and functions at different parts of the code. There are three main types of scope: global scope, function...

easy5 min·FunctionsJavascript
67

Explain the concept of tagged templates

low

Tagged templates in JavaScript allow you to parse template literals with a function. The function receives the literal strings and the values as arguments, enabling cus...

easy5 min·Data Types & VariablesJavascript
68

Explain the concept of test-driven development (TDD)

low

Test-driven development (TDD) is a software development approach where you write tests before writing the actual code. The process involves writing a failing test, writ...

easy5 min·TestingJavascriptTesting
69

Explain the concept of the Prototype pattern

low

The Prototype pattern is a creational design pattern used to create new objects by copying an existing object, known as the prototype. This pattern is useful when the c...

easy5 min·Design PatternsJavascript
70

Explain the concept of the Singleton pattern

low

The Singleton pattern ensures that a class has only one instance and provides a global point of access to that instance. This is useful when exactly one object is neede...

easy5 min·Design PatternsJavascript
71

Explain the concept of the spread operator and its uses

low

The spread operator (`...`) in JavaScript allows you to expand elements of an iterable (like an array or object) into individual elements. It is commonly used for copyi...

easy5 min·Operators & Control FlowJavascript
72

Explain the concept of the Strategy pattern

low

The Strategy pattern is a behavioral design pattern that allows you to define a family of algorithms, encapsulate each one as a separate class, and make them interchang...

easy5 min·Design PatternsJavascript
73

Explain the concept of the Web Socket API

low

The WebSocket API provides a way to open a persistent connection between a client and a server, allowing for real-time, two-way communication. Unlike HTTP, which is req...

easy5 min·Web APIs & Browser APIsJavascriptNetwork
74

Explain the concept of tree shaking in module bundling

low

Tree shaking is a technique used in module bundling to eliminate dead code, which is code that is never used or executed. This helps to reduce the final bundle size and...

easy5 min·ModulesJavascript
75

Explain the difference between `document.querySelector()` and `document.getElementById()`

low

`document.querySelector()` and `document.getElementById()` are both methods used to select elements from the DOM, but they have key differences. `document.querySelector...

easy5 min·DOM Manipulation & EventsJavascriptHtml
76

Explain the difference between classical inheritance and prototypal inheritance

low

Classical inheritance is a model where classes inherit from other classes, typically seen in languages like Java and C++. Prototypal inheritance, used in JavaScript, in...

easy5 min·Prototypes & InheritanceJavascript
77

Explain the difference between dot notation and bracket notation for accessing object properties

low

Dot notation and bracket notation are two ways to access properties of an object in JavaScript. Dot notation is more concise and readable but can only be used with vali...

easy5 min·Objects & ArraysJavascript
78

Explain the difference between global scope, function scope, and block scope

low

Global scope means variables are accessible from anywhere in the code. Function scope means variables are accessible only within the function they are declared in. Bloc...

easy5 min·Closures & ScopeJavascript
79

Explain the difference between shallow copy and deep copy

low

A shallow copy duplicates the top-level properties of an object, but nested objects are still referenced. A deep copy duplicates all levels of an object, creating entir...

easy5 min·Objects & ArraysJavascript
80

Explain the difference between unit testing, integration testing, and end-to-end testing

low

Unit testing focuses on testing individual components or functions in isolation to ensure they work as expected. Integration testing checks how different modules or ser...

easy5 min·TestingJavascriptTesting
81

Explain the difference in hoisting between `var`, `let`, and `const`

low

`var` declarations are hoisted to the top of their scope and initialized with `undefined`, allowing them to be used before their declaration. `let` and `const` declarat...

easy5 min·HoistingJavascript
82

Explain the different states of a Promise

low

A `Promise` in JavaScript can be in one of three states: `pending`, `fulfilled`, or `rejected`. When a `Promise` is created, it starts in the `pending` state. If the op...

easy5 min·Asynchronous JavaScriptJavascript
83

Explain the different ways the `this` keyword can be bound

low

The `this` keyword in JavaScript can be bound in several ways:

easy5 min·This KeywordJavascript
84

Explain the event phases in a browser

low

In a browser, events go through three phases: capturing, target, and bubbling. During the capturing phase, the event travels from the root to the target element. In the...

easy5 min·DOM Manipulation & EventsJavascript
85

Explain the Observer pattern and its use cases

low

The Observer pattern is a design pattern where an object, known as the subject, maintains a list of its dependents, called observers, and notifies them of any state cha...

easy5 min·Design PatternsJavascript
86

Explain the same-origin policy with regards to JavaScript

low

The same-origin policy is a security measure implemented in web browsers to prevent malicious scripts on one page from accessing data on another page. It ensures that w...

hard5 min·GeneralJavascriptNetworkSecurity
87

Explain why the following doesn't work as an IIFE: `function foo(){}();`. What needs to be changed to properly make it an IIFE?

low

The code `function foo(){}();` doesn't work as an Immediately Invoked Function Expression (IIFE) because the JavaScript parser treats `function foo(){}` as a function d...

hard5 min·GeneralJavascript
88

How can closures be used to create private variables?

low

Closures in JavaScript can be used to create private variables by defining a function within another function. The inner function has access to the outer function's var...

easy5 min·Closures & ScopeJavascript
89

How can you avoid problems related to hoisting?

low

To avoid problems related to hoisting, always declare variables at the top of their scope using `let` or `const` instead of `var`. This ensures that variables are block...

easy5 min·HoistingJavascript
90

How can you create custom error objects?

low

To create custom error objects in JavaScript, you can extend the built-in `Error` class. This allows you to add custom properties and methods to your error objects. Her...

easy5 min·Error HandlingJavascript
91

How can you implement secure authentication and authorization in JavaScript applications?

low

To implement secure authentication and authorization in JavaScript applications, use HTTPS to encrypt data in transit, and store sensitive data like tokens securely usi...

easy5 min·SecurityJavascriptSecurity
92

How can you optimize DOM manipulation for better performance?

low

To optimize DOM manipulation for better performance, minimize direct DOM access and updates. Use techniques like batching DOM changes, using `documentFragment` for mult...

easy5 min·Performance OptimizationJavascriptPerformance
93

How can you optimize network requests for better performance?

low

To optimize network requests for better performance, you can minimize the number of requests, use caching, compress data, and leverage modern web technologies like HTTP...

easy5 min·Performance OptimizationJavascriptPerformance
94

How can you prevent clickjacking attacks?

low

To prevent clickjacking attacks, you can use the `X-Frame-Options` HTTP header to control whether your site can be embedded in iframes. Set it to `DENY` to prevent all...

easy5 min·SecurityJavascriptSecurity
95

How can you prevent SQL injection vulnerabilities in JavaScript applications?

low

To prevent SQL injection vulnerabilities in JavaScript applications, always use parameterized queries or prepared statements instead of string concatenation to construc...

easy5 min·SecurityJavascriptSecurity
96

How can you share code between JavaScript files?

low

To share code between JavaScript files, you can use modules. In modern JavaScript, you can use ES6 modules with `export` and `import` statements. For example, you can e...

medium5 min·GeneralJavascript
97

How can you test asynchronous code in JavaScript?

low

To test asynchronous code in JavaScript, you can use testing frameworks like Jest or Mocha. These frameworks provide built-in support for handling asynchronous operatio...

easy5 min·TestingJavascriptTesting
98

How do `<iframe>` on a page communicate?

low

`<iframe>` elements on a page can communicate using the `postMessage` API. This allows for secure cross-origin communication between the parent page and the iframe. The...

easy5 min·Web APIs & Browser APIsJavascriptHtml
99

How do `Set`s and `Map`s handle equality checks for objects?

low

`Set`s and `Map`s in JavaScript handle equality checks for objects based on reference equality, not deep equality. This means that two objects are considered equal only...

easy5 min·Sets & MapsJavascript
100

How do currying and partial application differ from each other?

low

Currying transforms a function with multiple arguments into a sequence of functions, each taking a single argument. For example, a function `f(a, b, c)` becomes `f(a)(b...

easy5 min·Currying & Partial ApplicationJavascript
101

How do you access the index of an element in an array during iteration?

low

To access the index of an element in an array during iteration, you can use methods like `forEach`, `map`, `for...of` with `entries`, or a traditional `for` loop. For e...

easy5 min·Operators & Control FlowJavascript
102

How do you add, remove, and modify HTML elements using JavaScript?

low

To add, remove, and modify HTML elements using JavaScript, you can use methods like `createElement`, `appendChild`, `removeChild`, and properties like `innerHTML` and `...

easy5 min·DOM Manipulation & EventsJavascriptHtml
103

How do you add, remove, and update elements in an array?

low

To add elements to an array, you can use methods like `push`, `unshift`, or `splice`. To remove elements, you can use `pop`, `shift`, or `splice`. To update elements, y...

easy5 min·Objects & ArraysJavascript
104

How do you check if an object has a specific property?

low

To check if an object has a specific property, you can use the `in` operator or the `hasOwnProperty` method. The `in` operator checks for both own and inherited propert...

easy5 min·Objects & ArraysJavascript
105

How do you check the data type of a variable?

low

To check the data type of a variable in JavaScript, you can use the `typeof` operator. For example, `typeof variableName` will return a string indicating the type of th...

easy5 min·Data Types & VariablesJavascript
106

How do you convert a `Set` to an array in JavaScript?

low

To convert a `Set` to an array in JavaScript, you can use the `Array.from()` method or the spread operator. For example:

easy5 min·Sets & MapsJavascript
107

How do you convert a string to a number in JavaScript?

low

In JavaScript, you can convert a string to a number using several methods. The most common ones are `Number()`, `parseInt()`, `parseFloat()`, and the unary plus operato...

easy5 min·Data Types & VariablesJavascript
108

How do you create a constructor function?

low

To create a constructor function in JavaScript, define a regular function with a capitalized name to indicate it's a constructor. Use the `this` keyword to set properti...

easy5 min·Prototypes & InheritanceJavascript
109

How do you detect if JavaScript is disabled on a page?

low

To detect if JavaScript is disabled on a page, you can use the `<noscript>` HTML tag. This tag allows you to display content or messages to users who have JavaScript di...

easy5 min·Web APIs & Browser APIsJavascript
110

How do you get the query string values of the current page in JavaScript?

low

To get the query string values of the current page in JavaScript, you can use the `URLSearchParams` object. First, create a `URLSearchParams` instance with `window.loca...

easy5 min·Web APIs & Browser APIsJavascript
111

How do you handle errors in asynchronous operations?

low

To handle errors in asynchronous operations, you can use `try...catch` blocks with `async/await` syntax or `.catch()` method with Promises. For example, with `async/awa...

easy5 min·Asynchronous JavaScriptJavascript
112

How do you handle errors using `try...catch` blocks?

low

To handle errors using `try...catch` blocks, you wrap the code that might throw an error inside a `try` block. If an error occurs, the control is transferred to the `ca...

easy5 min·Error HandlingJavascript
113

How do you import and export modules in JavaScript?

low

In JavaScript, you can import and export modules using the `import` and `export` statements. To export a module, you can use `export` before a function, variable, or cl...

easy5 min·ModulesJavascript
114

How do you make an HTTP request using the Fetch API?

low

To make an HTTP request using the Fetch API, you can use the `fetch` function, which returns a promise. You can handle the response using `.then()` and `.catch()` for e...

easy5 min·Web APIs & Browser APIsJavascriptNetwork
115

How do you manipulate CSS styles using JavaScript?

low

You can manipulate CSS styles using JavaScript by accessing the `style` property of an HTML element. For example, to change the background color of a `div` element with...

easy5 min·DOM Manipulation & EventsJavascriptCss
116

How do you organize your code?

low

I organize my code by following a modular approach, using a clear folder structure, and adhering to coding standards and best practices. I separate concerns by dividing...

medium5 min·GeneralJavascript
117

How do you prevent the default behavior of an event?

low

To prevent the default behavior of an event in JavaScript, you can use the `preventDefault` method on the event object. For example, if you want to prevent a form from...

easy5 min·DOM Manipulation & EventsJavascript
118

How do you redirect to a new page in JavaScript?

low

To redirect to a new page in JavaScript, you can use the `window.location` object. The most common methods are `window.location.href` and `window.location.replace()`. F...

easy5 min·Web APIs & Browser APIsJavascript
119

How do you reliably determine whether an object is empty?

low

To reliably determine whether an object is empty, you can use `Object.keys()` to check if the object has any enumerable properties. If the length of the array returned...

easy5 min·Objects & ArraysJavascript
120

How do you use `window.history` API?

low

The `window.history` API allows you to manipulate the browser's session history. You can use `history.pushState()` to add a new entry to the history stack, `history.rep...

easy5 min·Web APIs & Browser APIsJavascript
121

How do you validate form elements using the Constraint Validation API?

low

The Constraint Validation API provides a way to validate form elements in HTML. You can use properties like `validity`, `validationMessage`, and methods like `checkVali...

easy5 min·Web APIs & Browser APIsJavascript
122

How do you write unit tests for JavaScript code?

low

To write unit tests for JavaScript code, you typically use a testing framework like Jest or Mocha. First, you set up your testing environment by installing the necessar...

easy5 min·TestingJavascriptTesting
123

How does hoisting affect function declarations and expressions?

low

Hoisting in JavaScript means that function declarations are moved to the top of their containing scope during the compile phase, making them available throughout the en...

easy5 min·HoistingJavascript
124

How is `Promise.all()` different from `Promise.allSettled()`?

low

`Promise.all()` and `Promise.allSettled()` are both methods for handling multiple promises in JavaScript, but they behave differently. `Promise.all()` waits for all pro...

easy5 min·Asynchronous JavaScriptJavascript
125

Provide some examples of how currying and partial application can be used

low

Currying transforms a function with multiple arguments into a sequence of functions, each taking a single argument. Partial application fixes a few arguments of a funct...

easy5 min·Currying & Partial ApplicationJavascript
126

What are `Set`s and `Map`s and how are they used?

low

`Set`s and `Map`s are built-in JavaScript objects that help manage collections of data. A `Set` is a collection of unique values, while a `Map` is a collection of key-v...

easy5 min·Sets & MapsJavascript
127

What are callback functions and how are they used?

low

A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or actio...

easy5 min·FunctionsJavascript
128

What are default parameters and how are they used?

low

Default parameters in JavaScript allow you to set default values for function parameters if no value or `undefined` is passed. This helps avoid `undefined` values and m...

easy5 min·FunctionsJavascript
129

What are design patterns and why are they useful?

low

Design patterns are reusable solutions to common problems in software design. They provide a template for how to solve a problem that can be used in many different situ...

easy5 min·Design PatternsJavascript
130

What are event listeners and how are they used?

low

Event listeners are functions that wait for specific events to occur on elements, such as clicks or key presses. They are used to execute code in response to these even...

easy5 min·DOM Manipulation & EventsJavascript
131

What are mocks and stubs and how are they used in testing?

low

Mocks and stubs are tools used in testing to simulate the behavior of real objects. Stubs provide predefined responses to function calls, while mocks are more complex a...

easy5 min·TestingJavascriptTesting
132

What are modules and why are they useful?

low

Modules are reusable pieces of code that can be imported and exported between different files in a project. They help in organizing code, making it more maintainable an...

easy5 min·ModulesJavascript
133

What are Progressive Web Applications (PWAs)?

low

Progressive Web Applications (PWAs) are web applications that use modern web capabilities to deliver an app-like experience to users. They are reliable, fast, and engag...

easy5 min·Web APIs & Browser APIsJavascript
134

What are Promises and how do they work?

low

Promises in JavaScript are objects that represent the eventual completion (or failure) of an asynchronous operation and its resulting value. They have three states: `pe...

easy5 min·Asynchronous JavaScriptJavascript
135

What are proxies in JavaScript used for?

low

In JavaScript, a proxy is an object that acts as an intermediary between an object and the code. Proxies are used to intercept and customize the fundamental operations...

easy5 min·GeneralFeaturedJavascript
136

What are rest parameters and how are they used?

low

Rest parameters in JavaScript allow a function to accept an indefinite number of arguments as an array. They are denoted by three dots (`...`) followed by the name of t...

easy5 min·Operators & Control FlowJavascript
137

What are some best practices for handling sensitive data in JavaScript?

low

Handling sensitive data in JavaScript requires careful attention to security practices. Avoid storing sensitive data in client-side storage like localStorage or session...

easy5 min·SecurityJavascriptSecurity
138

What are some best practices for writing maintainable and effective tests in JavaScript?

low

To write maintainable and effective tests, ensure they are clear, concise, and focused on a single behavior. Use descriptive names for test cases and avoid hardcoding v...

easy5 min·TestingJavascriptTesting
139

What are some common performance bottlenecks in JavaScript applications?

low

Common performance bottlenecks in JavaScript applications include inefficient DOM manipulation, excessive use of global variables, blocking the main thread with heavy c...

easy5 min·Performance OptimizationJavascriptPerformance
140

What are some common security headers and their purpose?

low

Security headers are HTTP response headers that help protect web applications from various attacks. Some common security headers include:

easy5 min·SecurityJavascriptSecurity
141

What are some of the advantages/disadvantages of writing JavaScript code in a language that compiles to JavaScript?

low

Using languages that compile to JavaScript, like TypeScript or CoffeeScript, can offer several advantages such as improved syntax, type safety, and better tooling. Howe...

medium5 min·GeneralJavascript
142

What are some popular JavaScript testing frameworks?

low

Some popular JavaScript testing frameworks include Jest, Mocha, Jasmine, and Cypress. Jest is known for its simplicity and integration with React. Mocha is highly flexi...

easy5 min·TestingJavascriptTesting
143

What are some techniques for reducing reflows and repaints?

low

To reduce reflows and repaints, you can minimize DOM manipulations, batch DOM changes, use CSS classes for style changes, avoid complex CSS selectors, and use `requestA...

easy5 min·Performance OptimizationJavascriptPerformance
144

What are some tools and techniques for identifying security vulnerabilities in JavaScript code?

low

To identify security vulnerabilities in JavaScript code, you can use static code analysis tools like ESLint with security plugins, dynamic analysis tools like OWASP ZAP...

easy5 min·SecurityJavascriptSecurity
145

What are some tools that can be used for JavaScript testing?

low

For JavaScript testing, you can use tools like Jest, Mocha, Jasmine, and Cypress. Jest is popular for its ease of use and built-in features. Mocha is flexible and can b...

easy5 min·TestingJavascriptTesting
146

What are some tools that can be used to measure and analyze JavaScript performance?

low

To measure and analyze JavaScript performance, you can use tools like Chrome DevTools, Lighthouse, WebPageTest, and JSPerf. Chrome DevTools provides a Performance panel...

easy5 min·Performance OptimizationJavascriptPerformance
147

What are template literals and how are they used?

low

Template literals are a feature in JavaScript that allow for easier string interpolation and multi-line strings. They are enclosed by backticks (`` ` ``) instead of sin...

easy5 min·Data Types & VariablesJavascript
148

What are the advantages of using the spread operator with arrays and objects?

low

The spread operator (`...`) in JavaScript allows you to easily copy arrays and objects, merge them, and add new elements or properties. It simplifies syntax and improve...

easy5 min·Objects & ArraysJavascript
149

What are the benefits of using a module bundler?

low

Using a module bundler like Webpack, Rollup, or Parcel helps manage dependencies, optimize performance, and improve the development workflow. It combines multiple JavaS...

easy5 min·ModulesJavascript
150

What are the benefits of using currying and partial application?

low

Currying transforms a function with multiple arguments into a sequence of functions, each taking a single argument. This allows for more flexible and reusable code. Par...

easy5 min·Currying & Partial ApplicationJavascript
151

What are the benefits of using spread syntax in JavaScript and how is it different from rest syntax?

low

**Spread syntax** (`...`) allows an iterable (like an array or string) to be expanded into individual elements. This is often used as a convenient and modern way to cre...

medium5 min·GeneralFeaturedJavascript
152

What are the common pitfalls of using the `this` keyword?

low

The `this` keyword in JavaScript can be tricky because its value depends on how a function is called. Common pitfalls include losing the context of `this` when passing...

easy5 min·This KeywordJavascript
153

What are the different methods for iterating over an array?

low

There are several methods to iterate over an array in JavaScript. The most common ones include `for` loops, `forEach`, `map`, `filter`, `reduce`, and `for...of`. Each m...

easy5 min·Objects & ArraysJavascript
154

What are the different types of errors in JavaScript?

low

In JavaScript, there are three main types of errors: syntax errors, runtime errors, and logical errors. Syntax errors occur when the code violates the language's gramma...

easy5 min·Error HandlingJavascript
155

What are the different types of testing in software development?

low

In software development, there are several types of testing to ensure the quality and functionality of the application. These include unit testing, integration testing,...

easy5 min·TestingJavascriptTesting
156

What are the different ways to copy an object or an array?

low

To copy an object or an array in JavaScript, you can use several methods. For shallow copies, you can use the spread operator (`...`) or `Object.assign()`. For deep cop...

easy5 min·Objects & ArraysJavascript
157

What are the different ways to make an API call in JavaScript?

low

In JavaScript, you can make API calls using several methods. The most common ones are `XMLHttpRequest`, `fetch`, and third-party libraries like `Axios`. `XMLHttpRequest...

easy5 min·Asynchronous JavaScriptJavascriptNetwork
158

What are the metadata fields of a module?

low

Metadata fields of a module typically include information such as the module's name, version, description, author, license, and dependencies. These fields are often fou...

easy5 min·ModulesJavascript
159

What are the potential issues caused by hoisting?

low

Hoisting can lead to unexpected behavior in JavaScript because variable and function declarations are moved to the top of their containing scope during the compilation...

easy5 min·HoistingJavascript
160

What are the potential pitfalls of using closures?

low

Closures can lead to memory leaks if not managed properly, especially when they capture variables that are no longer needed. They can also make debugging more difficult...

easy5 min·Closures & ScopeJavascript
161

What are the various data types in JavaScript?

low

In JavaScript, data types can be categorized into `primitive` and `non-primitive` types:

easy5 min·GeneralFeaturedJavascript
162

What are Web Workers and how can they be used to improve performance?

low

Web Workers are a way to run JavaScript in the background, separate from the main execution thread of a web application. This helps in performing heavy computations wit...

easy5 min·Performance OptimizationJavascriptPerformance
163

What do you think of AMD vs CommonJS?

low

AMD (Asynchronous Module Definition) and CommonJS are two JavaScript module systems. AMD is designed for asynchronous loading of modules, making it suitable for browser...

medium5 min·GeneralJavascript
164

What is `Object.freeze()` for?

low

`Object.freeze()` is used to make an object immutable. Once an object is frozen, you cannot add, remove, or modify its properties. This is useful for creating constants...

easy5 min·Objects & ArraysJavascript
165

What is `Object.preventExtensions()` for?

low

`Object.preventExtensions()` is a method in JavaScript that prevents new properties from being added to an object. However, it does not affect the deletion or modificat...

easy5 min·Objects & ArraysJavascript
166

What is `Object.seal()` for?

low

`Object.seal()` is used to prevent new properties from being added to an object and to mark all existing properties as non-configurable. This means you can still modify...

easy5 min·Objects & ArraysJavascript
167

What is async/await and how does it simplify asynchronous code?

low

`async/await` is a modern syntax in JavaScript that simplifies working with promises. By using the `async` keyword before a function, you can use the `await` keyword in...

easy5 min·Asynchronous JavaScriptJavascript
168

What is Cross-Site Scripting (XSS) and how can you prevent it?

low

Cross-Site Scripting (XSS) is a security vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users. This can lead to data the...

easy5 min·SecurityJavascriptSecurity
169

What is currying and how does it work?

low

Currying is a technique in functional programming where a function that takes multiple arguments is transformed into a series of functions that each take a single argum...

easy5 min·Currying & Partial ApplicationJavascript
170

What is recursion and how is it used in JavaScript?

low

Recursion is a programming technique where a function calls itself to solve a problem. In JavaScript, recursion is used to solve problems that can be broken down into s...

easy5 min·FunctionsJavascript
171

What is the `Intl` namespace object for?

low

The `Intl` namespace object in JavaScript is used for internationalization purposes. It provides language-sensitive string comparison, number formatting, and date and t...

easy5 min·Web APIs & Browser APIsJavascriptI18n
172

What is the Command pattern and how is it used?

low

The Command pattern is a behavioral design pattern that turns a request into a stand-alone object containing all information about the request. This transformation allo...

easy5 min·Design PatternsJavascript
173

What is the Decorator pattern and how is it used?

low

The Decorator pattern is a structural design pattern that allows behavior to be added to individual objects, dynamically, without affecting the behavior of other object...

easy5 min·Design PatternsJavascript
174

What is the difference between `event.preventDefault()` and `event.stopPropagation()`?

low

`event.preventDefault()` is used to prevent the default action that belongs to the event, such as preventing a form from submitting. `event.stopPropagation()` is used t...

easy5 min·DOM Manipulation & EventsJavascriptHtml
175

What is the difference between `innerHTML` and `textContent`?

low

`innerHTML` and `textContent` are both properties used to get or set the content of an HTML element, but they serve different purposes. `innerHTML` returns or sets the...

easy5 min·DOM Manipulation & EventsJavascriptHtml
176

What is the difference between `mouseenter` and `mouseover` event in JavaScript and browsers?

low

The main difference lies in the bubbling behavior of `mouseenter` and `mouseover` events. `mouseenter` does not bubble while `mouseover` bubbles.

easy5 min·GeneralFeaturedJavascriptHtml
177

What is the difference between `setTimeout()`, `setImmediate()`, and `process.nextTick()`?

low

`setTimeout()` schedules a callback to run after a minimum delay. `setImmediate()` schedules a callback to run after the current event loop completes. `process.nextTick...

easy5 min·Asynchronous JavaScriptJavascript
178

What is the difference between a parameter and an argument?

low

A parameter is a variable in the declaration of a function, while an argument is the actual value passed to the function when it is called. For example, in the function...

easy5 min·FunctionsJavascript
179

What is the difference between the Window object and the Document object?

low

The `Window` object represents the browser window and provides methods to control it, such as opening new windows or accessing the browser history. The `Document` objec...

easy5 min·Web APIs & Browser APIsJavascript
180

What is the DOM and how is it structured?

low

The DOM, or Document Object Model, is a programming interface for web documents. It represents the page so that programs can change the document structure, style, and c...

easy5 min·DOM Manipulation & EventsJavascriptHtml
181

What is the Factory pattern and how is it used?

low

The Factory pattern is a design pattern used to create objects without specifying the exact class of the object that will be created. It provides a way to encapsulate t...

easy5 min·Design PatternsJavascript
182

What is the Module pattern and how does it help with encapsulation?

low

The Module pattern in JavaScript is a design pattern used to create self-contained modules of code. It helps with encapsulation by allowing you to define private and pu...

easy5 min·Design PatternsJavascript
183

What is the prototype chain and how does it work?

low

The prototype chain is a mechanism in JavaScript that allows objects to inherit properties and methods from other objects. When you try to access a property on an objec...

easy5 min·Prototypes & InheritanceJavascript
184

What is the purpose of the `break` and `continue` statements?

low

The `break` statement is used to exit a loop or switch statement prematurely, while the `continue` statement skips the current iteration of a loop and proceeds to the n...

easy5 min·Operators & Control FlowJavascript
185

What is the purpose of the `finally` block?

low

The `finally` block in JavaScript is used to execute code after a `try` and `catch` block, regardless of whether an error was thrown or caught. It ensures that certain...

easy5 min·Error HandlingJavascript
186

What is the purpose of the `new` keyword?

low

The `new` keyword in JavaScript is used to create an instance of a user-defined object type or one of the built-in object types that has a constructor function. When yo...

easy5 min·Prototypes & InheritanceJavascript
187

What is the purpose of the `switch` statement?

low

The `switch` statement is used to execute one block of code among many based on the value of an expression. It is an alternative to using multiple `if...else if` statem...

easy5 min·Operators & Control FlowJavascript
188

What is the spread operator and how is it used?

low

The spread operator, represented by three dots (`...`), is used in JavaScript to expand iterable objects like arrays or strings into individual elements. It can also be...

easy5 min·Data Types & VariablesJavascript
189

What is the ternary operator and how is it used?

low

The ternary operator is a shorthand for an `if-else` statement in JavaScript. It takes three operands: a condition, a result for true, and a result for false. The synta...

easy5 min·Operators & Control FlowJavascript
190

What is the use of `Promise.all()`

low

`Promise.all()` is a method in JavaScript that takes an array of promises and returns a single promise. This returned promise resolves when all the input promises have...

easy5 min·Asynchronous JavaScriptJavascript
191

What language constructs do you use for iterating over object properties and array items in JavaScript?

low

There are multiple ways to iterate over object properties as well as arrays in JavaScript:

medium5 min·GeneralFeaturedJavascript
192

What tools and techniques do you use for debugging JavaScript code?

low

Some of the most commonly used tools and techniques for debugging JavaScript:

hard5 min·GeneralFeaturedJavascript
193

When would you use `document.write()`?

low

`document.write()` is rarely used in modern web development because it can overwrite the entire document if called after the page has loaded. It is mainly used for simp...

hard5 min·GeneralJavascriptHtml