JavaScript, React, Redux, Node.js, Express Flashcards
Explain the difference between var
, let
, and const
in JavaScript
var
is function-scoped, let
and const
are block-scoped, const
cannot be reassigned
How do closures work?
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.
What is the difference between class and functional components?
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 is Redux used in large React apps?
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 does the React lifecycle differ between functional components with hooks and class components?
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.
What is the React Context API?
The Context API is built into React to create a global state that can be accessed by any component in the application tree.
What is the role of Redux Saga?
Middleware for Redux that handles side effects like data fetching and asynchronous operations in a clean, manageable way
What is React?
A JavaScript library for building reusable user interface components, primarily for single-page applications
What is Node.js?
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.
What is the purpose of async/await?
async/await simplifies the syntax to consume promise-based APIs. Async functions always return a promise.
What is Express?
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 do you handle async operations in JavaScript?
Use promises or async/await
for cleaner syntax and better error handling
What is a Promise?
Promises represent an asynchronous operation that will eventually produce a value (resolved) or an error (rejected).
What is a REST API?
An API based on representational state transfer (REST) that uses HTTP requests to access and manipulate data and securely exchange information
How would you set up a REST API?
Use Express to configure middleware, define routes and controller functions