Master 193 curated questions covering the concepts most frequently tested at top companies — filtered by priority, topic, and difficulty.
Describe event bubbling in JavaScript and browsers
highEvent 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...
Describe event capturing in JavaScript and browsers
highEvent capturing is a lesser-used counterpart to [event bubbling](/questions/quiz/describe-event-bubbling) in the DOM event propagation mechanism. It follows the opposit...
Describe the difference between `<script>`, `<script async>` and `<script defer>`
highAll 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...
Describe the difference between a cookie, `sessionStorage` and `localStorage` in browsers
highAll 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...
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 |...
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...
Explain event delegation in JavaScript
highEvent 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...
Explain how `this` works in JavaScript
highThere'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...
Explain how prototypal inheritance works in JavaScript
highPrototypical inheritance in JavaScript is a way for objects to inherit properties and methods from other objects. Every JavaScript object has a special hidden property...
Explain the concept of "hoisting" in JavaScript
highThe following behavior summarizes the result of accessing the variables before they are declared.
Explain the difference between synchronous and asynchronous functions in JavaScript
highSynchronous functions are blocking while asynchronous functions are not. In synchronous functions, statements complete before the next statement is run. As a result, pr...
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...
What advantage is there for using the JavaScript arrow syntax for a method in a constructor?
highThe 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...
What are the differences between JavaScript ES2015 classes and ES5 function constructors?
highES2015 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...
What are the differences between JavaScript variables created using `let`, `var` or `const`?
highIn JavaScript, `let`, `var`, and `const` are all keywords used to declare variables, but they differ significantly in terms of scope, initialization rules, whether they...
What are the pros and cons of using Promises instead of callbacks in JavaScript?
highPromises offer a cleaner alternative to callbacks, helping to avoid callback hell and making asynchronous code more readable. They facilitate writing sequential and par...
What are the various ways to create objects in JavaScript?
highCreating objects in JavaScript offers several methods:
What is a closure in JavaScript, and how/why would you use one?
highIn 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:
What is the definition of a higher-order function in JavaScript?
highA 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.
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...
What is the event loop in JavaScript runtimes?
highThe event loop is concept within the browser runtime environment regarding how asynchronous operations are executed within JavaScript engines. It works as such:
What's a typical use case for anonymous functions in JavaScript?
highAnonymous 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...
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:
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...
Can you offer a use case for the new arrow => function syntax?
mediumArrow functions provide a concise syntax for writing functions in JavaScript. They are particularly useful for maintaining the `this` context within methods and callbac...
Explain AJAX in as much detail as possible
mediumAJAX (Asynchronous JavaScript and XML) facilitates asynchronous communication between the client and server, enabling dynamic updates to web pages without reloading. It...
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.
Explain the differences between CommonJS modules and ES modules in JavaScript
mediumIn JavaScript, modules are reusable pieces of code that encapsulate functionality, making it easier to manage, maintain, and structure your applications. Modules allow...
Explain what a single page app is and how to make one SEO-friendly
mediumA 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...
How do you abort a web request using `AbortController` in JavaScript?
medium`AbortController` is used to cancel ongoing asynchronous operations like fetch requests.
How does JavaScript garbage collection work?
mediumGarbage 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...
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...
What are iterators and generators in JavaScript and what are they used for?
mediumIn JavaScript, iterators and generators are powerful tools for managing sequences of data and controlling the flow of execution in a more flexible way.
What are JavaScript object getters and setters for?
mediumJavaScript 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...
What are JavaScript object property flags and descriptors?
mediumIn JavaScript, property flags and descriptors manage the behavior and attributes of object properties.
What are JavaScript polyfills for?
mediumPolyfills 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...
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...
What are the advantages and disadvantages of using AJAX?
mediumAJAX (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...
What are the differences between `Map`/`Set` and `WeakMap`/`WeakSet` in JavaScript?
mediumThe primary difference between `Map`/`Set` and `WeakMap`/`WeakSet` in JavaScript lies in how they handle keys. Here's a breakdown:
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...
What are workers in JavaScript used for?
mediumWorkers 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...
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.
What is the difference between a `Map` object and a plain object in JavaScript?
mediumBoth `Map` objects and plain objects in JavaScript can store key-value pairs, but they have several key differences:
What's the difference between an "attribute" and a "property" in the DOM?
mediumAttributes 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,...
Why is extending built-in JavaScript objects not a good idea?
mediumExtending 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...
Why is it, in general, a good idea to leave the global JavaScript scope of a website as-is and never touch it?
mediumJavaScript 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...
Why might you want to create static class members in JavaScript?
mediumStatic class members (properties/methods) has a `static` keyword prepended. Such members cannot be directly accessed on instances of the class. Instead, they're accesse...
Difference between document `load` event and document `DOMContentLoaded` event?
lowThe `DOMContentLoaded` event fires when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finis...
Explain how JSONP works (and how it's not really Ajax)
lowJSONP (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...
Explain the concept of `this` binding in event handlers
lowIn 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...
Explain the concept of a callback function in asynchronous operations
lowA 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....
Explain the concept of a microtask queue
lowThe 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...
Explain the concept of caching and how it can be used to improve performance
lowCaching 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...
Explain the concept of code coverage and how it can be used to assess test quality
lowCode 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...
Explain the concept of Content Security Policy (CSP) and how it enhances security
lowContent 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...
Explain the concept of Cross-Site Request Forgery (CSRF) and its mitigation techniques
lowCross-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...
Explain the concept of debouncing and throttling
lowDebouncing 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...
Explain the concept of destructuring assignment for objects and arrays
lowDestructuring 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...
Explain the concept of error propagation in JavaScript
lowError 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...
Explain the concept of hoisting with regards to functions
lowHoisting 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...
Explain the concept of inheritance in ES2015 classes
lowInheritance 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...
Explain the concept of input validation and its importance in security
lowInput 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...
Explain the concept of lazy loading and how it can improve performance
lowLazy 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...
Explain the concept of lexical scoping
lowLexical 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...
Explain the concept of partial application
lowPartial 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...
Explain the concept of scope in JavaScript
lowIn 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...
Explain the concept of tagged templates
lowTagged 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...
Explain the concept of test-driven development (TDD)
lowTest-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...
Explain the concept of the Prototype pattern
lowThe 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...
Explain the concept of the Singleton pattern
lowThe 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...
Explain the concept of the spread operator and its uses
lowThe 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...
Explain the concept of the Strategy pattern
lowThe 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...
Explain the concept of the Web Socket API
lowThe 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...
Explain the concept of tree shaking in module bundling
lowTree 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...
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...
Explain the difference between classical inheritance and prototypal inheritance
lowClassical inheritance is a model where classes inherit from other classes, typically seen in languages like Java and C++. Prototypal inheritance, used in JavaScript, in...
Explain the difference between dot notation and bracket notation for accessing object properties
lowDot 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...
Explain the difference between global scope, function scope, and block scope
lowGlobal 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...
Explain the difference between shallow copy and deep copy
lowA 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...
Explain the difference between unit testing, integration testing, and end-to-end testing
lowUnit testing focuses on testing individual components or functions in isolation to ensure they work as expected. Integration testing checks how different modules or ser...
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...
Explain the different states of a Promise
lowA `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...
Explain the different ways the `this` keyword can be bound
lowThe `this` keyword in JavaScript can be bound in several ways:
Explain the event phases in a browser
lowIn 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...
Explain the Observer pattern and its use cases
lowThe 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...
Explain the same-origin policy with regards to JavaScript
lowThe 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...
Explain why the following doesn't work as an IIFE: `function foo(){}();`. What needs to be changed to properly make it an IIFE?
lowThe code `function foo(){}();` doesn't work as an Immediately Invoked Function Expression (IIFE) because the JavaScript parser treats `function foo(){}` as a function d...
How can closures be used to create private variables?
lowClosures 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...
How can you avoid problems related to hoisting?
lowTo 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...
How can you create custom error objects?
lowTo 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...
How can you implement secure authentication and authorization in JavaScript applications?
lowTo implement secure authentication and authorization in JavaScript applications, use HTTPS to encrypt data in transit, and store sensitive data like tokens securely usi...
How can you optimize DOM manipulation for better performance?
lowTo optimize DOM manipulation for better performance, minimize direct DOM access and updates. Use techniques like batching DOM changes, using `documentFragment` for mult...
How can you optimize network requests for better performance?
lowTo optimize network requests for better performance, you can minimize the number of requests, use caching, compress data, and leverage modern web technologies like HTTP...
How can you prevent clickjacking attacks?
lowTo 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...
How can you prevent SQL injection vulnerabilities in JavaScript applications?
lowTo prevent SQL injection vulnerabilities in JavaScript applications, always use parameterized queries or prepared statements instead of string concatenation to construc...
How can you share code between JavaScript files?
lowTo 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...
How can you test asynchronous code in JavaScript?
lowTo test asynchronous code in JavaScript, you can use testing frameworks like Jest or Mocha. These frameworks provide built-in support for handling asynchronous operatio...
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...
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...
How do currying and partial application differ from each other?
lowCurrying 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...
How do you access the index of an element in an array during iteration?
lowTo 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...
How do you add, remove, and modify HTML elements using JavaScript?
lowTo add, remove, and modify HTML elements using JavaScript, you can use methods like `createElement`, `appendChild`, `removeChild`, and properties like `innerHTML` and `...
How do you add, remove, and update elements in an array?
lowTo 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...
How do you check if an object has a specific property?
lowTo 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...
How do you check the data type of a variable?
lowTo 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...
How do you convert a `Set` to an array in JavaScript?
lowTo convert a `Set` to an array in JavaScript, you can use the `Array.from()` method or the spread operator. For example:
How do you convert a string to a number in JavaScript?
lowIn 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...
How do you create a constructor function?
lowTo 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...
How do you detect if JavaScript is disabled on a page?
lowTo 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...
How do you get the query string values of the current page in JavaScript?
lowTo 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...
How do you handle errors in asynchronous operations?
lowTo 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...
How do you handle errors using `try...catch` blocks?
lowTo 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...
How do you import and export modules in JavaScript?
lowIn 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...
How do you make an HTTP request using the Fetch API?
lowTo 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...
How do you manipulate CSS styles using JavaScript?
lowYou 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...
How do you organize your code?
lowI 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...
How do you prevent the default behavior of an event?
lowTo 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...
How do you redirect to a new page in JavaScript?
lowTo 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...
How do you reliably determine whether an object is empty?
lowTo 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...
How do you use `window.history` API?
lowThe `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...
How do you validate form elements using the Constraint Validation API?
lowThe Constraint Validation API provides a way to validate form elements in HTML. You can use properties like `validity`, `validationMessage`, and methods like `checkVali...
How do you write unit tests for JavaScript code?
lowTo 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...
How does hoisting affect function declarations and expressions?
lowHoisting 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...
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...
Provide some examples of how currying and partial application can be used
lowCurrying 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...
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...
What are callback functions and how are they used?
lowA 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...
What are default parameters and how are they used?
lowDefault 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...
What are design patterns and why are they useful?
lowDesign 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...
What are event listeners and how are they used?
lowEvent 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...
What are mocks and stubs and how are they used in testing?
lowMocks 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...
What are modules and why are they useful?
lowModules 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...
What are Progressive Web Applications (PWAs)?
lowProgressive 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...
What are Promises and how do they work?
lowPromises in JavaScript are objects that represent the eventual completion (or failure) of an asynchronous operation and its resulting value. They have three states: `pe...
What are proxies in JavaScript used for?
lowIn 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...
What are rest parameters and how are they used?
lowRest 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...
What are some best practices for handling sensitive data in JavaScript?
lowHandling sensitive data in JavaScript requires careful attention to security practices. Avoid storing sensitive data in client-side storage like localStorage or session...
What are some best practices for writing maintainable and effective tests in JavaScript?
lowTo 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...
What are some common performance bottlenecks in JavaScript applications?
lowCommon performance bottlenecks in JavaScript applications include inefficient DOM manipulation, excessive use of global variables, blocking the main thread with heavy c...
What are some common security headers and their purpose?
lowSecurity headers are HTTP response headers that help protect web applications from various attacks. Some common security headers include:
What are some of the advantages/disadvantages of writing JavaScript code in a language that compiles to JavaScript?
lowUsing languages that compile to JavaScript, like TypeScript or CoffeeScript, can offer several advantages such as improved syntax, type safety, and better tooling. Howe...
What are some popular JavaScript testing frameworks?
lowSome popular JavaScript testing frameworks include Jest, Mocha, Jasmine, and Cypress. Jest is known for its simplicity and integration with React. Mocha is highly flexi...
What are some techniques for reducing reflows and repaints?
lowTo 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...
What are some tools and techniques for identifying security vulnerabilities in JavaScript code?
lowTo identify security vulnerabilities in JavaScript code, you can use static code analysis tools like ESLint with security plugins, dynamic analysis tools like OWASP ZAP...
What are some tools that can be used for JavaScript testing?
lowFor 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...
What are some tools that can be used to measure and analyze JavaScript performance?
lowTo measure and analyze JavaScript performance, you can use tools like Chrome DevTools, Lighthouse, WebPageTest, and JSPerf. Chrome DevTools provides a Performance panel...
What are template literals and how are they used?
lowTemplate literals are a feature in JavaScript that allow for easier string interpolation and multi-line strings. They are enclosed by backticks (`` ` ``) instead of sin...
What are the advantages of using the spread operator with arrays and objects?
lowThe 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...
What are the benefits of using a module bundler?
lowUsing a module bundler like Webpack, Rollup, or Parcel helps manage dependencies, optimize performance, and improve the development workflow. It combines multiple JavaS...
What are the benefits of using currying and partial application?
lowCurrying 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...
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...
What are the common pitfalls of using the `this` keyword?
lowThe `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...
What are the different methods for iterating over an array?
lowThere 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...
What are the different types of errors in JavaScript?
lowIn 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...
What are the different types of testing in software development?
lowIn software development, there are several types of testing to ensure the quality and functionality of the application. These include unit testing, integration testing,...
What are the different ways to copy an object or an array?
lowTo 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...
What are the different ways to make an API call in JavaScript?
lowIn JavaScript, you can make API calls using several methods. The most common ones are `XMLHttpRequest`, `fetch`, and third-party libraries like `Axios`. `XMLHttpRequest...
What are the metadata fields of a module?
lowMetadata fields of a module typically include information such as the module's name, version, description, author, license, and dependencies. These fields are often fou...
What are the potential issues caused by hoisting?
lowHoisting can lead to unexpected behavior in JavaScript because variable and function declarations are moved to the top of their containing scope during the compilation...
What are the potential pitfalls of using closures?
lowClosures 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...
What are the various data types in JavaScript?
lowIn JavaScript, data types can be categorized into `primitive` and `non-primitive` types:
What are Web Workers and how can they be used to improve performance?
lowWeb 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...
What do you think of AMD vs CommonJS?
lowAMD (Asynchronous Module Definition) and CommonJS are two JavaScript module systems. AMD is designed for asynchronous loading of modules, making it suitable for browser...
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...
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...
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...
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...
What is Cross-Site Scripting (XSS) and how can you prevent it?
lowCross-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...
What is currying and how does it work?
lowCurrying 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...
What is recursion and how is it used in JavaScript?
lowRecursion 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...
What is the `Intl` namespace object for?
lowThe `Intl` namespace object in JavaScript is used for internationalization purposes. It provides language-sensitive string comparison, number formatting, and date and t...
What is the Command pattern and how is it used?
lowThe 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...
What is the Decorator pattern and how is it used?
lowThe Decorator pattern is a structural design pattern that allows behavior to be added to individual objects, dynamically, without affecting the behavior of other object...
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...
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...
What is the difference between `mouseenter` and `mouseover` event in JavaScript and browsers?
lowThe main difference lies in the bubbling behavior of `mouseenter` and `mouseover` events. `mouseenter` does not bubble while `mouseover` bubbles.
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...
What is the difference between a parameter and an argument?
lowA 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...
What is the difference between the Window object and the Document object?
lowThe `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...
What is the DOM and how is it structured?
lowThe 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...
What is the Factory pattern and how is it used?
lowThe 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...
What is the Module pattern and how does it help with encapsulation?
lowThe 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...
What is the prototype chain and how does it work?
lowThe 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...
What is the purpose of the `break` and `continue` statements?
lowThe `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...
What is the purpose of the `finally` block?
lowThe `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...
What is the purpose of the `new` keyword?
lowThe `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...
What is the purpose of the `switch` statement?
lowThe `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...
What is the spread operator and how is it used?
lowThe 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...
What is the ternary operator and how is it used?
lowThe 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...
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...
What language constructs do you use for iterating over object properties and array items in JavaScript?
lowThere are multiple ways to iterate over object properties as well as arrays in JavaScript:
What tools and techniques do you use for debugging JavaScript code?
lowSome of the most commonly used tools and techniques for debugging JavaScript:
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...