Skip to content

Commit bd3a4cd

Browse files
committed
interviw questions day 1
1 parent 8a774d8 commit bd3a4cd

1 file changed

Lines changed: 116 additions & 0 deletions

File tree

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
1. React is a library because of its focus on a specific purpose (UI rendering) and flexibility to integrate with other tools.
2+
However, when combined with tools and libraries, it can be used as a framework-like solution.
3+
4+
5+
Definition: React is a JavaScript library developed by Facebook for building user interfaces, primarily for single-page applications.
6+
7+
2. Framwork vs Library
8+
9+
A framework is like a blueprint that defines the application's architecture and controls the flow, where you plug in your code (e.g., Angular).
10+
11+
12+
A library, on the other hand, is a toolset you call to perform specific tasks, keeping you in control of the flow (e.g., React).
13+
14+
15+
3. Real Dom vs Virtual Dom
16+
17+
REAL DOM
18+
19+
The actual Document Object Model (DOM) used by the browser to render the UI.
20+
It represents the structure of the web page as a tree of HTML nodes.
21+
22+
23+
VIRTUAL DOM
24+
25+
Definition:
26+
27+
A lightweight in-memory representation (or copy) of the Real DOM, used by frameworks like React.
28+
29+
30+
4. Fragment usage
31+
32+
Fragment is useful when you need to return multiple elements from a component without adding extra nodes to the DOM.
33+
34+
5. JSX - JSX (JavaScript XML) is a syntax extension for JavaScript, commonly used with React to describe what the UI should look like.
35+
It allows you to write HTML-like code within JavaScript, making it easier to create and manage UI components.
36+
37+
6. Render Method : The render() method in React is used to describe what should be displayed on the screen by returning JSX (or React.createElement) from a component.
38+
39+
7.Code splitting
40+
41+
Code splitting is a technique in web development, especially in React, that allows you to split your application’s
42+
bundle into smaller chunks or "splits" which can be loaded on demand, improving the initial load time and performance of your app.
43+
44+
8. What are the different ways to improve react
45+
46+
Code splitting, Use useMemo and useCallback Hooks,
47+
Lazy Load Images and Assets: Purpose: Improve performance by loading images and other assets only when they are visible in the viewport.
48+
49+
50+
9.
51+
useState: Ideal for managing simple state, where state updates are independent and don’t require complex logic.
52+
It’s a hook that returns an array with the current state value and a function to update it.
53+
54+
useReducer: Used for more complex state management, especially when the state updates depend on multiple actions or involve more logic.
55+
It provides a way to handle state transitions using actions and a reducer function, similar to Redux.
56+
57+
58+
10. A Higher-Order Component is a function that:
59+
60+
Takes a component as an argument.
61+
Returns a new component with additional logic or functionality.
62+
63+
11. When to Use an HOC:
64+
Code Reusability:
65+
66+
When you have common logic that needs to be shared across multiple components.
67+
Instead of duplicating the same code, you can wrap different components with the same HOC.
68+
69+
70+
12. A component in React is a reusable, self-contained unit of UI that accepts
71+
inputs (props) and returns a React element to be rendered on the screen.
72+
Class Component Functional Component
73+
74+
75+
13. Use Functional Components with hooks for new projects, modern React apps, and when you need state management or lifecycle features.
76+
Use Class Components if you’re working on legacy projects that still rely on class-based components,
77+
or if you prefer their syntax (though this is increasingly rare).
78+
Functional components are now the best practice in React development.
79+
80+
81+
14. Stateless: Often functional components in modern React (before hooks, they were class components).
82+
Stateful: Often class components in older React versions, but can also be functional components using hooks (useState, useEffect).
83+
84+
85+
15. useMemo:
86+
Purpose: Used to memoize the result of a computation (or value) so that React doesn't recompute it on every render unless the dependencies change.
87+
88+
When to Use useMemo vs useCallback:
89+
Use useMemo when you have a computation that you want to avoid re-running on every render, such as a filter, sort, or expensive calculation.
90+
Use useCallback when you're passing functions to child components and want to avoid creating a new function instance on every render,
91+
which can cause unnecessary re-renders of the child components.
92+
93+
94+
16. In HTML, multipart/form-data is the encoding type used for forms that handle large file uploads and mixed data
95+
(like text and files). By setting the enctype attribute to multipart/form-data
96+
97+
98+
17. fig vs img
99+
100+
Use Cases:
101+
102+
<img>: Used alone when you need to display an image.
103+
<figure>: Used when you want to group the image with its description, such as for articles,
104+
blogs, galleries, or any content where you need to associate media with additional context.
105+
106+
107+
18. How it Works: required attribute
108+
When the required attribute is added to a form element, the browser will check if the field has been filled out when the form is submitted.
109+
If the field is empty, the form submission will be prevented, and the browser will typically show a message indicating that the field is required.
110+
111+
112+
19. <marquee> tag was once commonly used to create scrolling content, it is now obsolete
113+
114+
115+
20. The <figcaption> tag is a useful HTML element for adding captions to images, videos, and other media elements.
116+

0 commit comments

Comments
 (0)