Add office photos
Engaged Employer

Tech Mahindra

3.6
based on 33k Reviews
Filter interviews by

10+ Interview Questions and Answers

Updated 3 Apr 2024
Popular Designations

Q1. What are the three stages of event propagation and how to handle it

Ans.

Event propagation consists of three stages: capturing, target, and bubbling.

  • Capturing phase: Events are captured from the outermost element to the target element.

  • Target phase: Event reaches the target element where the event originated.

  • Bubbling phase: Events bubble up from the target element to the outermost element.

Add your answer

Q2. What is difference between use reducer and use state

Ans.

useReducer is preferred for managing complex state logic, while useState is simpler for basic state management.

  • useReducer is more suitable for managing complex state logic and multiple state values

  • useState is simpler and more straightforward for basic state management with a single value

  • useReducer allows for more organized and centralized state updates through actions and reducers

  • useState is commonly used for simple component-level state management

Add your answer

Q3. How you will pass data from parent to child

Ans.

Data can be passed from parent to child components in React using props.

  • Pass data as props from parent component to child component

  • Use state management libraries like Redux or Context API for complex data sharing

  • Use callback functions to pass data from child to parent components

Add your answer

Q4. How to handle errors in your react application

Ans.

Errors in a React application can be handled by using error boundaries, try-catch blocks, and displaying error messages to users.

  • Use error boundaries to catch errors in components and display a fallback UI

  • Wrap code that may throw errors in try-catch blocks to handle exceptions

  • Use libraries like React Error Boundary to easily implement error handling

  • Display error messages to users to inform them about the issue and possible solutions

Add your answer
Discover null interview dos and don'ts from real experiences

Q5. Error boundary and how to handle

Ans.

Error boundary is a React component that catches JavaScript errors anywhere in a component tree and logs those errors.

  • Error boundaries are React components that catch JavaScript errors in their child component tree.

  • They are used to prevent the entire UI from crashing due to a single error.

  • Error boundaries work like a JavaScript catch {} block, but for components.

  • They are defined using componentDidCatch lifecycle method.

  • Example:

Add your answer

Q6. How you can clone an object

Ans.

To clone an object in JavaScript, you can use the spread operator or Object.assign() method.

  • Use the spread operator to create a shallow copy of an object: const clonedObj = { ...originalObj };

  • Use Object.assign() method to create a shallow copy of an object: const clonedObj = Object.assign({}, originalObj);

  • For deep cloning, you can use libraries like Lodash or write a custom function to recursively clone nested objects.

Add your answer
Are these interview questions helpful?

Q7. Explain map filter and reduce functions

Ans.

Map, filter, and reduce are higher-order functions in JavaScript used to manipulate arrays.

  • Map: Transforms each element in an array and returns a new array with the transformed elements.

  • Example: [1, 2, 3].map(num => num * 2) returns [2, 4, 6].

  • Filter: Returns a new array with elements that pass a certain condition.

  • Example: [1, 2, 3].filter(num => num > 1) returns [2, 3].

  • Reduce: Applies a function against an accumulator and each element in the array to reduce it to a single val...read more

Add your answer

Q8. What hooks you have used

Ans.

I have used React hooks such as useState, useEffect, useContext, and useRef in my projects.

  • useState

  • useEffect

  • useContext

  • useRef

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. Let var const in JavaScript

Ans.

var and const are used to declare variables in JavaScript, with var being mutable and const being immutable.

  • var is used to declare variables that can be reassigned and updated

  • const is used to declare variables that cannot be reassigned or updated

  • let is another keyword used for declaring variables, similar to var but with block scope

Add your answer

Q10. Write your own custom hook

Ans.

Custom hook to fetch data from an API

  • Create a function that uses the useState and useEffect hooks

  • Use the fetch API to make a request to the desired endpoint

  • Return the fetched data and loading state in an array

Add your answer

Q11. Use of never in typescript

Ans.

The 'never' type in TypeScript represents a value that will never occur.

  • Used to indicate that a function will not return a value

  • Commonly used in union types to exclude certain values

  • Helps catch potential errors at compile time

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at null

based on 4 interviews in the last 1 year
1 Interview rounds
Technical Round
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Front end Developer Interview Questions from Similar Companies

3.9
 • 15 Interview Questions
3.2
 • 15 Interview Questions
3.0
 • 14 Interview Questions
3.7
 • 12 Interview Questions
3.8
 • 10 Interview Questions
3.6
 • 10 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter