Interview Questions
Interview Questions
1. What is React?
Ans: A JavaScript library for building user interfaces.
2. What are the key features of React?
Ans:
Virtual DOM
component-based architecture
unidirectional data flow.
3. What is JSX? Why do we use it?
Ans: JSX is a syntax extension for JavaScript that allow us to write HTML-like
markup inside a JavaScript file. It makes the code more readable and expressive.
4. Explain the concept of Virtual DOM in React.
Ans: Virtual DOM is a concept in React where a lightweight, virtual representation
of the actual DOM (Document Object Model) is created and stored in memory.
5. What are components in React? Explain functional and class components.
Ans: Reusable building blocks of a UI. Functional components are stateless
functions, while class components are ES6 classes.
6. What is the difference between state and props in React?
Ans: Here is the difference between them.
State is mutable and local to a component
props are immutable and passed from parent to child.
7. What is a Higher-Order Component (HOC)?
Ans: A function that takes a component and returns an enhanced version of it.
8. Explain the concept of React reconciliation.
Ans: A process where React updates the Virtual DOM and applies changes to the
real DOM efficiently.
9. What are React fragments? Why are they used?
Ans: A way to group elements without adding extra nodes to the DOM. Syntax:
<></>.
10. What is the purpose of keys in React?
Ans: To uniquely identify elements for efficient list rendering.
11. What is React Context, and how do you use it?
Ans: A way to share data across components without props drilling.
12. What is React Router? How is it used for navigation?
Ans: A library for navigation in React apps using components like <Route> and
<Link>.
13. What are controlled and uncontrolled components in React?
Ans: Controlled components are managed via state; uncontrolled components use
refs.
JavaScript Interview Questions
1. What is JavaScript?
Ans: JavaScript is a synchronous single threaded language.
2. Explain the difference between var, let, and const.
Ans:
var: function-scoped,
let: block-scoped,
const: block-scoped and immutable.
3. What are JavaScript data types?
Ans:
Primitive: string, number, boolean, undefined, null, symbol, bigint.
Non-primitive: object.
4. What is the difference between == and === in JavaScript?
Ans:
== checks value;
=== checks value and type.
5. What are closures in JavaScript? Provide an example.
Ans:
A closure is the combination of a function bundled together (enclosed) with
references to its surrounding state (the lexical environment)
6. Explain the concept of event bubbling and event capturing.
Ans:
Bubbling: Event propagates from child to parent.
Capturing: Event propagates from parent to child.
7. What are promises in JavaScript?
Ans:
Promises is an object representing the eventual completion of an async operation.
8. What is the difference between null and undefined?
Ans:
null: explicitly empty;
undefined: not assigned.
9. Explain the concept of hoisting in JavaScript.
Ans:
Variables and functions are moved to the top of their scope during execution.
10. What is the purpose of async and await?
Ans:
Simplifies handling promises in asynchronous code.
11. What is the difference between map, filter, and forEach?
Ans:
map: transforms array,
filter: returns a filtered array,
forEach: iterates without returning.
Node.js Interview Questions