JavaScript, React, Redux, Node.js, Express Flashcards

1
Q

Explain the difference between var, let, and const in JavaScript

A

var is function-scoped, let and const are block-scoped, const cannot be reassigned

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do closures work?

A

A closure gives you access to an outer function’s scope from an inner function e.g.
function aFunc(x){ return () => console.log( x++ ) }
Practically, closures are commonly used to create private variables and methods in JavaScript.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between class and functional components?

A

Class components use ES6 class syntax, manage state with this.state and this.setState(), and have lifecycle methods like componentDidMount. Functional components use function syntax, manage state with Hooks like useState, and handle side effects with useEffect. Functional components are more straightforward and more concise.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How is Redux used in large React apps?

A

Redux is a global state management library for managing the state predictably using actions, reducers, and the store. The store holds the application’s state. Actions describe changes to the state. Reducers are pure functions that return a new state based on the action.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does the React lifecycle differ between functional components with hooks and class components?

A

Class components use lifecycle methods like componentDidMount, componentDidUpdate, and componentWillUnmount to manage side effects and state changes. Functional components use hooks, such as useState for state and useEffect for side effects. useEffect can mimic lifecycle methods with its dependencies and cleanup function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the React Context API?

A

The Context API is built into React to create a global state that can be accessed by any component in the application tree.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the role of Redux Saga?

A

Middleware for Redux that handles side effects like data fetching and asynchronous operations in a clean, manageable way

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is React?

A

A JavaScript library for building reusable user interface components, primarily for single-page applications

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is Node.js?

A

Node.js is a JavaScript runtime that allows developers to run JavaScript on the server side for full-stack development with a single programming language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the purpose of async/await?

A

async/await simplifies the syntax to consume promise-based APIs. Async functions always return a promise.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is Express?

A

Express is a minimal and flexible Node.js web application framework for building web servers and APIs with routing, middleware support, template engines, and other tools.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you handle async operations in JavaScript?

A

Use promises or async/await for cleaner syntax and better error handling

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a Promise?

A

Promises represent an asynchronous operation that will eventually produce a value (resolved) or an error (rejected).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a REST API?

A

An API based on representational state transfer (REST) that uses HTTP requests to access and manipulate data and securely exchange information

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How would you set up a REST API?

A

Use Express to configure middleware, define routes and controller functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Explain middleware in Express

A

Middleware functions process requests before reaching the route handler

17
Q

What is routing structure in Express?

A

Organize routes in separate files, e.g. routes/user.js for user-related endpoints

18
Q

How does Node.js handle multithreading?

A

Node.js uses a single-threaded event loop for non-blocking I/O operations by default, but we can use worker threads to offload CPI-intensive tasks.