DigiBoxx
Joshi Multispeciality Hospital Interview Questions and Answers
Q1. What are Hooks in ReactJs and Explain useState, useRef, useEffect Hooks with their usecases?
Hooks are functions that allow us to use state and other React features in functional components.
useState is a hook that allows us to add state to functional components.
useRef is a hook that allows us to create a mutable reference that persists across renders.
useEffect is a hook that allows us to perform side effects in functional components.
useState example: const [count, setCount] = useState(0);
useRef example: const inputRef = useRef(null);
useEffect example: useEffect(() =>...read more
Q2. How can you compose multiple HOCs with render props in a React component
Compose multiple HOCs with render props in a React component
Create a render prop component that accepts a function as a prop
Wrap the render prop component with HOCs
Pass the function as a prop to the HOCs
Use the function to render the component's content
Example: withAuth(withTheme(RenderPropComponent))
Q3. What are Components and state in ReactJs?
Components are reusable UI elements in ReactJs. State is an object that stores data and controls a component's behavior.
Components are like building blocks that can be combined to create complex UIs
State is used to store and manage data within a component
Changes to state trigger a re-render of the component
State should be kept as minimal as possible to avoid performance issues
Example: A button component can have a state that tracks the number of times it has been clicked
Q4. Explain setTimeout, setImmediate and process.nextTick ?
setTimeout, setImmediate and process.nextTick are Node.js functions used for asynchronous programming.
setTimeout is used to execute a function after a specified amount of time has passed.
setImmediate is used to execute a function immediately after the current event loop iteration.
process.nextTick is used to execute a function at the beginning of the next event loop iteration.
setTimeout and setImmediate are similar, but setImmediate has higher priority in the event loop.
proces...read more
Q5. What is life cycle in ReactJS ?
ReactJS life cycle refers to the series of methods that are invoked in the process of creating, updating and destroying a component.
ReactJS life cycle consists of three phases: Mounting, Updating and Unmounting.
Mounting phase includes methods like constructor, render, componentDidMount.
Updating phase includes methods like shouldComponentUpdate, render, componentDidUpdate.
Unmounting phase includes method componentWillUnmount.
These methods help in managing the state and props o...read more
Q6. What Algorithm you used in your Project?
I used the Dijkstra's algorithm for finding the shortest path in my project.
Implemented Dijkstra's algorithm to find the shortest path between nodes in a graph
Used priority queue to optimize the algorithm
Considered edge weights and node distances while calculating the shortest path
Q7. Purpose of getDerivedStateFromProps() and getSnapshotBeforeUpdate() Lifecyle method?
getDerivedStateFromProps() updates state based on props changes. getSnapshotBeforeUpdate() captures current state before update.
getDerivedStateFromProps() is called before rendering and updates state based on changes in props.
getSnapshotBeforeUpdate() is called after rendering but before updating the DOM. It captures current state before update.
getDerivedStateFromProps() is a static method and should return an object to update state or null to indicate no update.
getSnapshotBe...read more
Q8. Explain Local Storage, Session Storage, cache in Web development
Local Storage, Session Storage, and Cache are used to store data in the browser for faster access and better user experience.
Local Storage: stores data with no expiration date and can be accessed across multiple windows and tabs
Session Storage: stores data for a single session and is cleared when the session ends
Cache: stores data temporarily to reduce server load and improve performance
Examples: storing user preferences, caching images and scripts for faster page load
Q9. WeakMap and WeakSet in Javascript?
WeakMap and WeakSet are specialized collections in JavaScript that allow for weak references to objects.
WeakMap allows for mapping of objects to values where the object keys are weakly referenced.
WeakSet is a collection of objects where the objects are weakly referenced.
Weak references allow for objects to be garbage collected if they are no longer referenced elsewhere.
WeakMap and WeakSet are useful for scenarios where you want to associate data with an object without prevent...read more
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month