Infosys
30+ Tirupati Mahima Industries Interview Questions and Answers
Q1. What are higher-order functions in JS
Higher-order functions are functions that take one or more functions as arguments or return a function as their result.
Higher-order functions can be used to create reusable code by abstracting common patterns.
They enable functional programming paradigms like currying and composition.
Examples of higher-order functions in JavaScript include map, filter, and reduce.
Q2. What is the difference between a development dependency and a regular dependency in software development?
Development dependencies are needed for development and testing, while regular dependencies are needed for the application to run.
Development dependencies are used during the development process, such as testing frameworks or build tools.
Regular dependencies are required for the application to function properly in production.
Development dependencies are typically listed in the devDependencies section of package.json, while regular dependencies are listed in dependencies.
Examp...read more
Q3. presentation component vs functional component in React.js
Presentation components are class components that handle rendering, while functional components are simpler and handle stateless rendering.
Presentation components are also known as container components.
Functional components are also known as stateless components.
Presentation components are used for complex UI logic and state management.
Functional components are used for simple UI logic and stateless rendering.
Functional components are easier to test and maintain.
Example of pr...read more
Q4. What is hoisting in JS
Hoisting is a JavaScript behavior where variable and function declarations are moved to the top of their containing scope.
Hoisting applies to both variable and function declarations.
Variable declarations are hoisted but not their initializations.
Function declarations are fully hoisted, allowing them to be called before they are declared.
Hoisting does not apply to variables declared with let or const.
Hoisting can lead to unexpected behavior if not understood properly.
Q5. What do the symbols ^ and ~ represent in the package.json file?
Symbols ^ and ~ in package.json represent version ranges for dependencies.
The symbol ^ represents a range that allows minor version updates.
The symbol ~ represents a range that allows only patch updates.
For example, ^1.2.3 allows any version from 1.2.3 to <2.0.0, while ~1.2.3 allows any version from 1.2.3 to <1.3.0.
Q6. What is the component lifecycle in functional components?
Component lifecycle in functional components involves useEffect hook for side effects.
Functional components use useEffect hook to handle side effects like fetching data, subscribing to events, etc.
useEffect hook can be used to mimic componentDidMount, componentDidUpdate, and componentWillUnmount lifecycle methods.
useEffect hook takes a callback function as its first argument and an optional array of dependencies as its second argument.
The callback function inside useEffect ru...read more
Q7. Difference between var, let, and const in JS
var is function scoped, let and const are block scoped.
var can be redeclared and updated within its scope
let can be updated but not redeclared within its scope
const cannot be updated or redeclared once declared
let and const are not hoisted like var
const must be initialized during declaration
Q8. What is redux and when to use it and when not to use it?
Redux is a predictable state container for JavaScript apps. It is used to manage application state in a centralized way.
Use Redux when you have complex state management needs in your application.
Redux is helpful for large applications with many components that need access to the same state.
Avoid using Redux for simple applications with minimal state management requirements.
Consider using React's built-in state management for smaller applications or components.
Redux can be use...read more
Q9. What are lifecycle methods of react? How we can achieve same in functional components?
React lifecycle methods are methods that are invoked at different stages of a component's life cycle.
Some lifecycle methods include componentDidMount, componentDidUpdate, componentWillUnmount, etc.
In functional components, we can achieve similar functionality using useEffect hook.
For example, useEffect with an empty dependency array can mimic componentDidMount, while useEffect with dependencies can mimic componentDidUpdate.
Q10. How can a 404 page be handled in React routing?
404 page can be handled in React routing by creating a Route component with a path of '*' at the end of all other routes.
Create a Route component with a path of '*' at the end of all other routes in the Switch component.
Inside the '*' Route component, render a custom 404 page component.
Use the Switch component to ensure that only one Route is rendered at a time.
Q11. What is the checklist for improving performance of React application?
Checklist for improving performance of React application
Use React.memo or PureComponent for optimizing rendering
Avoid unnecessary re-renders by using shouldComponentUpdate or React.memo
Use code splitting to load only necessary components
Optimize state management with libraries like Redux or Context API
Minimize the use of inline styles and prefer CSS stylesheets for better performance
Q12. Git commands: How to commit ,merge code, how to resolve merge conflicts
Git commands for committing, merging code, and resolving merge conflicts
To commit code: git commit -m 'Commit message'
To merge code from a branch: git merge branch_name
To resolve merge conflicts: manually edit the conflicting files, add changes, and then commit the merge
Q13. Two arrays passed to one function, then remove the elements passed from source array and present in another array
Remove elements from source array present in another array passed to a function
Loop through elements in source array and check if they exist in the other array
If an element is found in both arrays, remove it from the source array
Q14. What are Hooks in React.js
Hooks are a feature in React.js that allow developers to use state and other React features in functional components.
Hooks are functions that let you use React features in functional components
They allow you to use state and other React features without writing a class
Hooks provide a way to reuse stateful logic between components
Some commonly used hooks are useState, useEffect, and useContext
Q15. Difference between var and let, difference between redux and flux
Var is function scoped, let is block scoped. Redux is a predictable state container, Flux is an architecture pattern.
Var can be redeclared and updated within its scope, let cannot be redeclared but can be updated within its scope
Redux has a single store for the entire application, while Flux has multiple stores
Redux uses a unidirectional data flow, while Flux uses a bidirectional data flow
Redux has middleware for handling side effects, while Flux does not have built-in suppor...read more
Q16. What is conditional rendering in React? What are closures? OOPS concept in JavaScript. What is ACID in database? Stack vs Heap
Conditional rendering in React allows components to render different elements or components based on certain conditions.
Conditional rendering is achieved using JavaScript expressions inside JSX.
Common conditional rendering techniques include using if statements, ternary operators, and logical && operator.
Example: rendering a component only if a certain condition is met - {condition ?
: null}
Q17. What is the difference between props and state?
Props are immutable and passed from parent component, while state is mutable and managed within the component.
Props are read-only and cannot be modified by the component receiving them.
State is mutable and can be changed by the component that owns it.
Props are passed from parent to child components, while state is managed within the component itself.
Example: Props can be used to pass data from a parent component to a child component, while state can be used to manage form inp...read more
Q18. What is the concept of redeclaration in JavaScript?
Redeclaration in JavaScript refers to the act of declaring a variable or function multiple times within the same scope.
Redeclaring a variable using the 'var' keyword will not throw an error but will simply update the value of the variable.
Redeclaring a variable using the 'let' or 'const' keyword within the same scope will result in a syntax error.
Redeclaring a function within the same scope will override the previous function definition.
Q19. What is redux? Explain its architecture.
Redux is a predictable state container for JavaScript apps.
Redux is a state management library commonly used with React.
It helps in managing the state of the application in a predictable way.
Redux follows a unidirectional data flow architecture.
Actions are dispatched to update the state, which is stored in a single immutable state tree.
Reducers are pure functions that specify how the state should change in response to actions.
Q20. When do we use any in typescript?
The 'any' type in TypeScript is used when the type of a variable is not known during development.
Use 'any' when working with dynamic data types or when the type cannot be determined at compile time.
Avoid using 'any' as much as possible to maintain type safety and improve code quality.
Consider using 'unknown' type instead of 'any' for better type checking and error prevention.
Q21. What are the benefits of React?
React offers a component-based architecture, virtual DOM for performance optimization, and a strong community support.
Component-based architecture allows for reusability and easier maintenance of code.
Virtual DOM helps in improving performance by only updating the necessary parts of the actual DOM.
React has a strong community support with a vast ecosystem of libraries and tools available.
React allows for server-side rendering for better SEO performance.
React Native allows for...read more
Q22. What is useReducer and UseContext api?
useReducer is a React hook that manages state changes through a specified reducer function. useContext is a hook that allows access to a context object.
useReducer is used for managing complex state logic in React applications.
It takes in a reducer function and an initial state, and returns the current state and a dispatch function.
Example: const [state, dispatch] = useReducer(reducer, initialState);
useContext is used for accessing context values in React components.
It takes a...read more
Q23. What is function currying
Function currying is a technique of transforming a function that takes multiple arguments into a sequence of functions that each take a single argument.
Currying allows partial application of a function.
It helps in creating reusable functions.
Curried functions are composable and can be easily combined to create new functions.
Currying can be achieved using closures or by using libraries like Lodash or Ramda.
Example: const add = x => y => x + y; add(2)(3) returns 5.
Q24. What is closures in js
Closures are functions that have access to variables in their outer scope, even after the outer function has returned.
Closures are created when a function is defined inside another function.
The inner function has access to the outer function's variables and parameters.
Closures can be used to create private variables and methods.
Closures can also be used to create functions with pre-set arguments.
Q25. What is one way data binding?
One way data binding is a unidirectional flow of data from the model to the view in React applications.
Data flows from the model (or source of truth) to the view, but not vice versa.
Changes in the model automatically update the view, but changes in the view do not affect the model.
Helps in maintaining a clear and predictable data flow in React components.
Q26. Tell me hooks you have used?
I have used useState, useEffect, useContext, useReducer, and useRef hooks in my projects.
useState - for managing state in functional components
useEffect - for handling side effects in functional components
useContext - for accessing context in functional components
useReducer - for managing complex state logic in functional components
useRef - for accessing DOM elements or storing mutable values
Q27. What is useEffect ?
useEffect is a hook in React that allows you to perform side effects in functional components.
It replaces componentDidMount, componentDidUpdate, and componentWillUnmount.
It takes two arguments: a function that performs the side effect and an array of dependencies.
The function is called after every render, unless the dependencies haven't changed.
Common use cases include fetching data, setting up event listeners, and updating the document title.
Example: useEffect(() => { docume...read more
Q28. What is hoisting ?
Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope.
Variables declared with var are hoisted to the top of their scope
Function declarations are hoisted before variables
Function expressions are not hoisted
Hoisting can lead to unexpected behavior and bugs
Q29. Explain redux data flow
Redux data flow is a unidirectional flow of data in React applications using a centralized store.
Actions are dispatched to the store
Reducers update the state based on the action
Components subscribe to the store to access the updated state
Q30. Difference between state and props?
State is mutable and managed within the component, while props are immutable and passed from parent component.
State is managed within the component and can be changed using setState() method
Props are passed from parent component to child component and cannot be changed by the child component
State is used for internal component data management, while props are used for passing data from parent to child components
Q31. What is redux middleware
Redux middleware is a function that intercepts actions before they reach the reducer.
Middleware can be used for logging, crash reporting, asynchronous API calls, etc.
It sits between the action dispatch and the reducer.
Examples of popular middleware include redux-thunk and redux-saga.
Q32. What is DOM tree?
DOM tree is a hierarchical representation of HTML elements in a web page.
DOM stands for Document Object Model.
It is a tree-like structure where each node represents an HTML element.
The DOM tree is created by the browser when a web page is loaded.
It allows JavaScript to manipulate the content, structure, and style of a web page.
Q33. what are closures in JS
Closures in JavaScript are functions that have access to variables from their outer scope even after the outer function has finished executing.
Closures allow functions to access variables from their parent function even after the parent function has returned.
They help in creating private variables and data encapsulation.
Closures are created whenever a function is defined within another function.
Q34. What are Promises?
Promises in JavaScript are objects representing the eventual completion or failure of an asynchronous operation.
Promises are used to handle asynchronous operations in JavaScript.
They can be in one of three states: pending, fulfilled, or rejected.
Promises can be chained using .then() to handle success and .catch() to handle errors.
Example: const myPromise = new Promise((resolve, reject) => { ... });
Interview Process at Tirupati Mahima Industries
Top Reactjs Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month