0% found this document useful (0 votes)
3 views

Interview Questions Answers

The document contains a series of interview questions and answers related to JavaScript, React, and CSS. Key topics include the differences between `var`, `let`, and `const`, the concept of closures, the use of React Hooks, and the CSS box model. It also highlights the distinctions between functional and class components in React and explains how `z-index` works in CSS.

Uploaded by

Guneet Thind
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Interview Questions Answers

The document contains a series of interview questions and answers related to JavaScript, React, and CSS. Key topics include the differences between `var`, `let`, and `const`, the concept of closures, the use of React Hooks, and the CSS box model. It also highlights the distinctions between functional and class components in React and explains how `z-index` works in CSS.

Uploaded by

Guneet Thind
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Interview Questions and Answers

### JavaScript Questions and Answers

1. **What is the difference between `var`, `let`, and `const`?**

- `var`: Function-scoped, hoisted, and allows re-declaration.

- `let`: Block-scoped, not hoisted, and does not allow re-declaration.

- `const`: Block-scoped and its value cannot be reassigned.

2. **Explain closures in JavaScript with an example.**

- A closure is a function that retains access to its lexical scope even when the function is executed

outside that scope.

- Example:

```javascript

function outer() {

let count = 0;

return function inner() {

count++;

return count;

};

const increment = outer();

console.log(increment()); // Output: 1

console.log(increment()); // Output: 2

```
### React Questions and Answers

1. **What are React Hooks?**

- React Hooks are functions that let you use state and lifecycle methods in functional components.

- Example: `useState`, `useEffect`.

2. **What is the difference between functional and class components?**

- Functional components are stateless and simpler, while class components support state and

lifecycle methods.

### CSS Questions and Answers

1. **What is the box model in CSS?**

- The box model includes `margin`, `border`, `padding`, and `content`. It defines how elements are

displayed and spaced.

2. **How does z-index work in CSS?**

- `z-index` determines the stacking order of elements. Higher values are displayed on top.

... (This will be expanded with full content)

You might also like