Online

Frontend Cases

FrontendCases is a quick way to recap what you already know in frontend. It's not for learning from scratch — just short, story-style refreshers to help you remember key fixes and ideas.

Filter by Technology (12 available)

Showing 144 of 144 questions
Q1

What is the difference between var, let, and const?

var is function-scoped and hoisted, let and const are block-scoped. const cannot be reassigned but can have mutable properties. Use const by default, let when you need to reassign.

JavaScript
Q2

Explain event delegation and why it's useful

Event delegation is attaching a single event listener to a parent element instead of multiple listeners to child elements. It's useful for dynamic content, better performance, and cleaner code.

JavaScriptHTML
Q3

What is the virtual DOM in React?

The virtual DOM is a lightweight JavaScript representation of the real DOM. React uses it to batch updates and minimize direct DOM manipulation, improving performance through diffing and reconciliation.

React
Q4

What are React hooks and why were they introduced?

Hooks are functions that let you use state and other React features in functional components. They were introduced to simplify code reuse, make components easier to understand, and eliminate class component complexity.

React
Q5

Explain CSS specificity and how it works

CSS specificity determines which styles apply when multiple rules target the same element. Calculated as: inline styles (1000) > IDs (100) > classes/attributes (10) > elements (1). Higher specificity wins.

CSSHTML
Q6

What is closure in JavaScript?

A closure is a function that has access to variables from its outer scope even after the outer function has returned. It's created every time a function is created and allows data privacy and function factories.

JavaScript
Q7

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

== performs type coercion before comparison, while === checks both value and type without coercion. Always use === to avoid unexpected behavior and bugs.

JavaScript
Q8

Explain the difference between async/await and promises

Both handle asynchronous code, but async/await is syntactic sugar over promises. async/await is more readable and allows using try/catch for error handling, making code look synchronous.

JavaScript
Q9

Design a URL shortener service (like bit.ly)

Use a hash function to generate short codes, store mappings in a database. Consider: collision handling, expiration, analytics tracking, rate limiting, and caching with Redis for frequently accessed URLs.

JavaScript
Q10

Design a real-time chat application

Use WebSockets for real-time communication, message queue (RabbitMQ/Kafka) for reliability, database for persistence, Redis for caching active users, and load balancing for scalability.

JavaScript
Q11

Design a rate limiter

Implement using token bucket or sliding window algorithm. Store request counts in Redis with TTL, return 429 status when limit exceeded. Consider per-user, per-IP, and global limits.

JavaScript
Q12

Design a caching layer for a web application

Use multi-level caching: browser cache (HTTP headers), CDN for static assets, Redis for application cache, database query cache. Implement cache invalidation strategies like TTL and event-based updates.

JavaScript
Q13

Design a notification system

Use message queue (Kafka/RabbitMQ) for reliability, multiple channels (email, SMS, push), database for notification history, and retry logic for failed deliveries.

JavaScript
Q14

What is the event loop in JavaScript?

The event loop is a mechanism that allows JavaScript to perform non-blocking asynchronous operations by using a call stack, callback queue, and tasks/ microtasks queues to manage execution order.

JavaScript
Q15

What is memoization and how can it improve performance?

Memoization caches the results of expensive function calls and returns cached results when the same inputs occur again, reducing redundant computations and improving performance.

JavaScript
Q16

Explain the useEffect hook in React and common pitfalls

useEffect performs side effects in functional components, like data fetching or subscriptions. Pitfalls include missing dependencies leading to stale data or infinite loops if useEffect updates dependencies improperly.

React
Q17

What are React keys and why are they important?

Keys are unique identifiers used by React to track elements in lists for efficient re-rendering. They help React detect which items changed, added, or removed, improving reconciliation performance.

React
Q18

How does Vue's reactivity system work?

Vue uses reactive getters/setters (Vue 2) or proxies (Vue 3) to track dependencies and notify components when data changes, triggering efficient DOM updates.

Vue
Q19

What is the difference between controlled and uncontrolled components in React?

Controlled components' form data is managed by React state, while uncontrolled components manage data through the DOM. Controlled provides better React integration and validation control.

React
Q20

Explain JavaScript's prototype chain

The prototype chain is how JavaScript objects inherit properties and methods through links between objects. When accessing a property, JS looks up the prototype chain until found or null.

JavaScript
Q21

What are higher-order components (HOCs) in React?

HOCs are functions that take a component and return a new enhanced component, enabling code reuse, logic abstraction, and manipulating props.

React
Q22

How do Vue directives work and name some common ones?

Vue directives are special tokens in the template that tell Vue to apply reactive behavior to DOM elements. Common directives include v-if, v-for, v-model, and v-bind.

Vue
Q23

What is event bubbling and how can you stop it?

Event bubbling is when an event propagates from the target element up through parent elements. You can stop it with e.stopPropagation() in the event handler.

JavaScriptHTML
Q24

What are some new features introduced in ES6?

ES6 introduced let/const, arrow functions, template literals, default parameters, destructuring, classes, modules, promises, and more for modern JavaScript development.

JavaScript
Q25

Explain Vue lifecycle hooks and their purpose

Vue lifecycle hooks are functions called at different stages of a component's lifecycle, like created, mounted, updated, and destroyed, used to run code at specific moments.

Vue
Q26

What is JSX and how does React use it?

JSX is a syntax extension that looks like HTML but is transformed to JavaScript calls (React.createElement). It allows writing UI structure in a declarative and intuitive way.

React
Q27

How do you optimize React application performance?

Use React.memo, useCallback, useMemo, lazy loading, code splitting, and avoid unnecessary renders to optimize React app performance.

React
Q28

What is the difference between Vue 2 and Vue 3?

Vue 3 introduces proxy-based reactivity, Composition API, improved TypeScript support, smaller bundle size, better performance, and tree-shaking compared to Vue 2's options API and Object.defineProperty reactivity.

Vue
Q29

Explain the difference between synchronous and asynchronous code in JavaScript

Synchronous code runs sequentially, blocking execution until complete. Asynchronous code runs alongside other operations using callbacks, promises, or async/await without blocking.

JavaScript
Q30

What is a Promise in JavaScript?

A Promise represents a value that may be available now, later, or never. It allows attaching callbacks for success (then) or failure (catch) of asynchronous operations.

JavaScript
Q31

How do you handle state management in Vue?

Vue apps use Vuex or Pinia for centralized state management, providing a single source of truth and predictable state mutations across components.

Vue
Q32

What is a closure in JavaScript?

A closure allows a function to access variables from its lexical scope even after the outer function has finished execution, enabling data encapsulation and private variables.

JavaScript
Q33

Describe the Vue Composition API and its benefits

Composition API organizes component logic by feature rather than lifecycle hooks, improving code readability, reuse, and TypeScript integration compared to Options API.

Vue
Q34

How do you pass data between React components?

Use props for parent-to-child data flow, callbacks to send data child-to-parent, and context API or state management libraries for global shared state.

React
Q35

What is a design system and why is it important for frontend development?

A design system is a collection of reusable components, guidelines, and standards that ensure consistency and scalability in UI design and development across a product or organization.

CSSHTMLJavaScript
Q36

Explain CSS Flexbox and when to use it

Flexbox provides a flexible layout model for arranging items in a container either horizontally or vertically, allowing alignment, space distribution, and reordering with ease, ideal for responsive layouts.

CSS
Q37

What are ARIA attributes and how do they improve accessibility?

ARIA (Accessible Rich Internet Applications) attributes provide additional semantic information to assistive technologies, improving the accessibility of dynamic content and custom UI components.

HTMLAccessibility
Q38

How does CSS Grid differ from Flexbox?

CSS Grid is a 2-dimensional layout system for rows and columns, suitable for complex layouts, while Flexbox is 1-dimensional for laying out items in a single row or column.

CSS
Q39

What is semantic HTML and why is it important?

Semantic HTML uses meaningful tags (like <article>, <nav>, <header>) which improve accessibility, SEO, and maintainability by clearly describing content purpose and structure.

HTML
Q40

Explain the difference between rem, em, and px units in CSS

px is an absolute pixel unit; em is relative to the font size of the parent element; rem is relative to the root (html) font size. rem and em enable scalable, responsive designs.

CSS
Q41

What is the box model in CSS?

The CSS box model describes the rectangular boxes generated for elements, including content, padding, border, and margin areas, affecting layout and spacing.

CSS
Q42

How do you ensure web accessibility for users with disabilities?

Use semantic HTML, ARIA attributes, keyboard navigability, color contrast, alt text for images, and test with screen readers to ensure your website is accessible.

HTMLCSSAccessibility
Q43

Explain the difference between inline, block, and inline-block elements

Block elements start on a new line and take full width, inline elements flow within text without line breaks, inline-block behaves like inline but accepts block properties like width and height.

CSS
Q44

What is a CSS preprocessor and what are the benefits?

CSS preprocessors like SASS or LESS add programming features (variables, nesting, mixins) to CSS for better maintainability, modularity, and reusability.

CSSSASSLESS
Q45

How do you implement responsive web design?

By using flexible grids, media queries, flexible images, and CSS units like %, em, and rem to adapt the layout and content across various screen sizes and devices.

CSSHTML
Q46

What is progressive enhancement and how does it relate to accessibility?

Progressive enhancement delivers basic content and functionality to all browsers while adding advanced features for modern browsers, improving accessibility and user experience.

HTMLCSSJavaScript
Q47

How do you handle focus management in web accessibility?

Use tabindex properly, manage focus order logically, ensure visible focus indicators, and trap focus within modals or dialogs to support keyboard users.

HTMLJavaScript
Q48

What are CSS pseudo-classes and give examples?

Pseudo-classes define a special state of an element, e.g., :hover, :focus, :nth-child(), enabling styling based on user interaction or element position.

CSS
Q49

What is the difference between visibility: hidden and display: none in CSS?

visibility: hidden hides the element but it still occupies space in the layout; display: none removes the element from the layout flow entirely.

CSS
Q50

Describe how to create a reusable UI component in a design system

Define visual style, behavior, and accessibility guidelines; build modular code with clear API, documentation, and test for reusability and consistency across apps.

CSSJavaScriptHTML
Q51

How can you optimize CSS delivery to improve frontend performance?

Minimize and compress CSS files, use critical CSS inline for above-the-fold content, load non-critical styles asynchronously, and avoid unused CSS.

CSS
Q52

Explain how role attributes enhance accessibility

The role attribute defines the semantic purpose of an element (e.g., role='button') to help assistive technologies understand and interact with custom or non-semantic elements.

HTML
Q53

What strategies do you use to handle cross-browser compatibility?

Use feature detection, CSS prefixes, polyfills, progressive enhancement, testing on different browsers, and avoid deprecated or non-standard features.

CSSJavaScriptHTML
Q54

How does the 'tabindex' attribute work and how do you use it?

tabindex controls keyboard navigation order: positive numbers set explicit order, 0 makes element focusable in natural order, -1 removes from tab navigation but can be focused programmatically.

HTML
Q55

What techniques can improve frontend web performance?

Techniques include minimizing HTTP requests, lazy loading images, code splitting, caching assets, minimizing CSS/JS, using CDN, optimizing images, and reducing render-blocking resources.

CSSJavaScriptHTML
Q56

Explain the concept of lazy loading and its benefits

Lazy loading defers loading offscreen or non-critical resources until needed, improving initial load time and reducing bandwidth for faster, more efficient user experiences.

JavaScriptHTML
Q57

Describe the critical rendering path in browsers

It's the sequence of steps browsers take to convert HTML, CSS, and JavaScript into pixels on the screen, including parsing, style calculation, layout, painting, and compositing. Optimizing it improves page load speed.

CSSJavaScriptHTML
Q58

What is a Content Delivery Network (CDN) and why use it?

A CDN is a distributed network of servers that delivers content to users based on geographic location, reducing latency, speeding up asset loading, and improving reliability and scalability.

JavaScriptHTMLCSS
Q59

How do you design scalable frontend architecture?

Use component-based structure, modular CSS, state management, lazy loading, code splitting, API layer abstraction, and automated testing for maintainability and scalability.

JavaScriptReactVueCSS
Q60

What is REST API and its core principles?

REST (Representational State Transfer) is an architectural style for APIs using stateless communication, uniform interface, and resource-based URLs with HTTP methods like GET, POST, PUT, DELETE.

JavaScriptHTTP
Q61

Explain the difference between REST and GraphQL APIs

REST exposes multiple endpoints for data resources; GraphQL exposes a single endpoint and allows clients to specify exactly what data they need, reducing over-fetching and under-fetching.

JavaScriptAPI
Q62

What strategies help prevent API over-fetching and under-fetching?

Use GraphQL to query only needed data, implement pagination, filtering, field selection, and versioning in REST APIs to optimize payload size and response time.

JavaScriptAPI
Q63

How do you handle API error states on the frontend?

Use try/catch or .catch for promises, show user-friendly error messages, implement retry mechanisms, fallback UI states, and log errors for diagnostics.

JavaScriptReactVue
Q64

Explain caching strategies for APIs

Use client-side cache, HTTP cache headers (ETag, Cache-Control), service workers for offline support, and server-side caching to reduce server load and improve response time.

JavaScriptHTTP
Q65

What is debounce and throttle? When to use them?

Debounce delays a function call until after a wait period of inactivity; throttle limits calls to a function to one per interval. Use debounce for search inputs and throttle for scroll or resize events.

JavaScript
Q66

How do you structure a large React application?

Organize by feature or domain, use reusable components, separate containers and presentational components, manage state with Context or Redux, and use code splitting for faster loads.

ReactJavaScript
Q67

Describe API versioning and why it matters

API versioning manages changes to an API without breaking existing clients, using URI versioning, header versioning, or custom strategies to maintain backwards compatibility.

JavaScriptHTTP
Q68

What are web workers and how do they improve performance?

Web workers run scripts in background threads separate from the main UI thread, preventing blocking and improving performance for heavy or async computations.

JavaScript
Q69

Explain Cross-Origin Resource Sharing (CORS)

CORS is a browser security feature that restricts web pages from making requests to a different domain unless the server allows it via specific headers, enabling controlled resource sharing.

JavaScriptHTTP
Q70

What is the difference between synchronous and asynchronous API calls?

Synchronous calls block execution until a response is received forcing sequential execution; asynchronous calls do not block and allow multiple operations to happen simultaneously.

JavaScript
Q71

How do you ensure security in API design?

Use HTTPS, authentication (OAuth, JWT), input validation, rate limiting, CORS policy, and proper error handling to prevent common vulnerabilities.

JavaScriptHTTP
Q72

Explain server-side rendering (SSR) vs client-side rendering (CSR)

SSR renders the initial HTML on the server improving SEO and load speed; CSR renders content in the browser using JavaScript improving rich interactivity but may delay time-to-first-paint.

ReactVueJavaScript
Q73

How do you handle pagination in API responses?

Use limit and offset or cursor-based pagination to limit data return per request, improving performance and user experience with large datasets.

JavaScript
Q74

What is the role of OpenAPI/Swagger in API development?

OpenAPI/Swagger provide standards and tools for describing, consuming, and testing RESTful APIs, enhancing documentation, client generation, and validation.

JavaScript
Q75

How do you implement debounce in JavaScript?

Debounce delays the execution of a function until a certain time has passed since it was last called, preventing excessive calls during events like scrolling or typing.

JavaScript
Q76

How to create a simple image carousel in JavaScript?

Use an array of images, track the current index, and update the displayed image on navigation button clicks or automatic timer intervals.

JavaScript
Q77

How to flatten a nested array in JavaScript?

Use recursion or array.flat(Infinity) to convert nested arrays into a single-level array.

JavaScript
Q78

What is the use of the 'classnames' utility and how to implement a simple version?

'classnames' merges class names conditionally into a single string. A simple implementation concatenates truthy string arguments.

JavaScript
Q79

How do you implement throttle in JavaScript?

Throttle limits function execution to once per interval regardless of how many times it’s triggered, useful for scroll or resize events.

JavaScript
Q80

How to perform a deep clone of an object in JavaScript?

Use recursion to copy all properties and nested objects to a new object, or use structuredClone() in modern environments.

JavaScript
Q81

How to merge two objects deeply in JavaScript?

Recursively combine properties of both objects, merging nested objects instead of overwriting.

JavaScript
Q82

What is a closure and how is it used in JavaScript?

A closure is a function that retains access to its lexical scope even when executed outside that scope, enabling data encapsulation and private variables.

JavaScript
Q83

How to implement a stack data structure in JavaScript?

Use an array to push, pop, and peek elements following LIFO (Last In First Out) principle.

JavaScript
Q84

How do you implement a queue in JavaScript?

Use an array with push to enqueue and shift to dequeue, following FIFO (First In First Out) principle.

JavaScript
Q85

How to implement a debounce function with leading and trailing options?

Allows controlling whether the function triggers on the leading and/or trailing edge of the timeout window.

JavaScript
Q86

What is the difference between shallow copy and deep copy?

Shallow copy copies top-level properties, referencing nested objects; deep copy recursively clones nested objects creating independent copies.

JavaScript
Q87

How do you check if two objects are deeply equal?

Recursively check all properties and nested objects for equality, handling different object types accordingly.

JavaScript
Q88

How to implement a simple memoize function in JavaScript?

Caches results of expensive function calls to optimize repeated calls with the same arguments.

JavaScript
Q89

How to reverse a linked list in JavaScript?

Iterate through the list, reversing pointers by keeping track of previous, current, and next nodes.

JavaScript
Q90

How to implement the Fibonacci sequence using recursion and memoization?

Recursive calculation with memoization to avoid redundant computation.

JavaScript
Q91

How do you implement a simple event emitter in JavaScript?

Allows subscribing, emitting, and unsubscribing events with callbacks.

JavaScript
Q92

How do you implement a binary search algorithm in JavaScript?

Search a sorted array by repeatedly dividing the search interval in half.

JavaScript
Q93

How do you convert RGB to Hex color format in JavaScript?

Convert each RGB channel to a two-digit hex string and concatenate.

JavaScript
Q94

What is the difference between map(), forEach(), and reduce() in JavaScript?

map() returns a new array with transformed elements; forEach() executes a function on each item without returning; reduce() aggregates array to a single value.

JavaScript
Q95

What is Next.js and what are its main features?

Next.js is a React framework for server-side rendering (SSR), static site generation (SSG), API routes, and hybrid apps offering improved performance and SEO.

ReactNext.js
Q96

Explain the difference between getStaticProps and getServerSideProps in Next.js

getStaticProps fetches data at build time for static generation; getServerSideProps fetches data on each request for server-side rendering.

Next.js
Q97

What is Incremental Static Regeneration (ISR) in Next.js?

ISR allows static pages to be regenerated on-demand at runtime, combining benefits of static and dynamic rendering with revalidation intervals.

Next.js
Q98

How do API routes work in Next.js?

API routes let you create backend endpoints inside the Next.js app under the /api directory, enabling serverless functions without additional server setup.

Next.jsJavaScript
Q99

How to configure custom routing in Next.js?

Next.js uses file-based routing inside the pages directory; dynamic routes are created using bracket syntax like [id].js, and catch-all routes with [[...slug]].js.

Next.jsReact
Q100

What are middleware in Next.js and how are they used?

Middleware runs before requests to pre-process or rewrite routes, protect pages, or add headers, enabling advanced routing and authentication logic.

Next.js
Q101

How do you handle environment variables in Next.js?

Use .env.local, .env.development, or .env.production files with NEXT_PUBLIC_ prefix for client-side variables; process.env is accessible on server-side.

Next.js
Q102

What is the Image component in Next.js and its benefits?

The Image component optimizes images with lazy loading, resizing, and caching for improved performance and better Core Web Vitals scores.

Next.js
Q103

How does Next.js support internationalization (i18n)?

Next.js has built-in i18n routing and locale detection, allowing localization of URLs and content with easy configuration in next.config.js.

Next.js
Q104

How to deploy a Next.js application?

You can deploy Next.js apps on platforms like Vercel, Netlify, or any Node.js server; Vercel offers optimized support including ISR, serverless functions, and edge middleware.

Next.js
Q105

Explain static site generation (SSG) and server-side rendering (SSR) trade-offs in Next.js

SSG offers faster load times and lower server costs but is less dynamic; SSR provides always fresh data but with performance and scalability trade-offs.

Next.js
Q106

What is the difference between client-side routing and server-side routing in Next.js?

Client-side routing uses the Next.js Link component to navigate without page reload; server-side routing involves full page requests for initial HTML generation or API calls.

Next.js
Q107

How can you prefetch pages in Next.js?

Next.js automatically prefetches linked pages in the viewport using the Link component; you can also manually trigger prefetch() for enhanced performance.

Next.js
Q108

How does Next.js handle CSS and styling options?

Supports global CSS, CSS Modules, styled-jsx, and integration with CSS-in-JS libraries like styled-components and emotion for scoped and dynamic styles.

Next.jsCSSJavaScript
Q109

How do you use dynamic API routes in Next.js?

Create files with bracket syntax inside /api (e.g., [id].js) to access dynamic parameters via req.query for flexible API endpoints.

Next.js
Q110

What are Next.js custom Document and custom App, and when to use them?

Custom Document (_document.js) enhances the HTML document structure; Custom App (_app.js) wraps all pages for shared layout, state, or styles.

Next.js
Q111

How does Next.js support middleware caching and edge functions?

Next.js middleware can run at the edge with caching headers to improve performance and deliver personalized content globally with low latency.

Next.js
Q112

Explain how Next.js handles data fetching in client components

Client components can fetch data inside useEffect or via SWR/React Query libraries for client-side caching and revalidation.

Next.jsReact
Q113

What is Next.js Image Optimization API and why use it?

The API optimizes image loading by automatic resizing, lazy loading, and modern formats, improving load speed and bandwidth.

Next.js
Q114

How to enable TypeScript in a Next.js project?

Create a tsconfig.json file and install @types/react/@types/node; Next.js auto-detects TypeScript and configures accordingly.

Next.jsTypeScript
Q115

How does Next.js handle static file serving?

Next.js serves static files from the /public directory, accessible via the root URL path, allowing easy inclusion of images, fonts, and other assets.

Next.js
Q116

What are the benefits of using next/link over a regular anchor tag?

next/link enables client-side navigation without full page reloads, improves prefetching of linked pages, and retains app state for faster, smoother transitions.

Next.js
Q117

How do you use getStaticPaths in Next.js?

getStaticPaths is used with getStaticProps to specify dynamic paths to pre-render at build time when using static generation for dynamic routes.

Next.js
Q118

How do you implement authentication in Next.js?

Use middleware for route protection, NextAuth.js or custom API routes for authentication flows, and secure cookies or JWT for session management.

Next.jsJavaScript
Q119

What is the difference between client component and server component in Next.js 13?

Server components are rendered on the server without sending JS to the client, improving performance, while client components render on the client enabling interactivity.

Next.jsReact
Q120

How do you handle error pages in Next.js?

Create a custom 404.js or _error.js in the pages directory to handle not found and general errors with custom UI and error reporting.

Next.js
Q121

How can you improve SEO with Next.js?

Use SSR/SSG for pre-rendered HTML, dynamic meta tags with next/head, sitemap generation, and semantic HTML for better crawlability and indexing.

Next.js
Q122

What is the role of the next.config.js file?

It allows configuring Next.js features like custom webpack config, environment variables, image domains, internationalization, redirects, and rewrites.

Next.js
Q123

Explain dynamic imports in Next.js and their benefits

Dynamic imports allow loading React components or modules asynchronously, enabling code splitting and faster initial page loads by reducing bundle size.

Next.jsReact
Q124

How do you implement global state management in a Next.js app?

Use React Context, Redux, Zustand, or other state libraries and integrate with Next.js lifecycle for SSR compatibility and hydration.

Next.jsReact
Q125

What are middleware matchers in Next.js?

Matchers define which routes middleware applies to, allowing granular control over middleware execution per path or patterns.

Next.js
Q126

How do you create API middleware in Next.js?

Middleware functions intercept API requests for authentication, logging, or request modification before reaching the final API handler.

Next.js
Q127

What is the use of Rewrites in Next.js?

Rewrites map an incoming request path to a different destination path without changing the URL, useful for masking URLs or API proxying.

Next.js
Q128

How do you add custom headers in Next.js responses?

Use middleware or API route handlers to set custom HTTP headers on responses for security or caching policies.

Next.js
Q129

Explain how Next.js handles CSS Module support

CSS Modules locally scope styles by default, preventing class name collisions and allowing CSS imports into components for scoped styling.

Next.jsCSS
Q130

What are fallback pages in Next.js dynamic routes?

Fallback pages display when a dynamic route isn’t pre-rendered; fallback: true allows generating pages on demand with loading UI, fallback: blocking delays rendering until data loads.

Next.js
Q131

How can you analyze bundle size in Next.js?

Use the built-in next build --stats or third-party tools like Webpack Bundle Analyzer to identify large dependencies and optimize accordingly.

Next.js
Q132

How do you implement custom error logging in Next.js?

Override _error.js for frontend errors, use API middleware for backend errors, and integrate services like Sentry or LogRocket for centralized logging.

Next.js
Q133

How does Next.js support image placeholders for better UX?

Next.js Image component supports placeholder='blur' to show a low-quality blurred image while the main image loads, improving visual stability and UX.

Next.js
Q134

How do you handle form submissions in Next.js?

Use controlled React forms with API routes to handle submissions, or external services; integrate validation libraries and handle client/server validation.

Next.jsReact
Q135

What are the main benefits of using TypeScript over JavaScript?

TypeScript adds static typing, early error detection, better tooling with IntelliSense, enhanced code readability, and scalability for large projects.

TypeScript
Q136

What is the difference between 'any' and 'unknown' types?

'any' disables type checking allowing any value, while 'unknown' is safer by requiring type checking before usage, preventing unintended errors.

TypeScript
Q137

Explain TypeScript interfaces and how they differ from types

Interfaces define contracts for object shapes and can be extended or implemented; types are more versatile allowing unions, intersections, and primitives.

TypeScript
Q138

What are generics in TypeScript and why are they useful?

Generics enable writing reusable, type-safe functions or classes by allowing parameters and return types to be specified dynamically upon usage.

TypeScript
Q139

How does TypeScript handle type inference?

TypeScript automatically infers the type of variables and return values when types are not explicitly declared, improving developer experience without verbosity.

TypeScript
Q140

What is a union type and how do you use it?

Union types allow a variable to hold values of multiple specified types, enabling flexible API designs and safer type checks.

TypeScript
Q141

Explain type assertion in TypeScript

Type assertion tells the compiler to treat a value as a specific type, overriding inferred types without changing runtime behavior.

TypeScript
Q142

What is the difference between 'interface' and 'type alias'?

Interfaces are open and extendable for objects and classes; type aliases are closed and can represent primitives, unions, tuples, or intersections.

TypeScript
Q143

How do you make properties optional in TypeScript?

Use the '?' syntax after property names in interfaces or types to declare them as optional.

TypeScript
Q144

Explain keyof operator in TypeScript

keyof returns a union of string literals representing all keys of a given type, useful for dynamic property access and type-safe APIs.

TypeScript
Created by Moumen Soliman