Module-3 Flashcards

1
Q

What is Array.prototype.filter useful for?

A

Useful for filtering arrays.

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

What is Array.prototype.map useful for?

A

Useful for transforming an array.

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

What is Array.prototype.reduce useful for?

A

Useful for returning a single value from an array.

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

What is “syntactic sugar”?

A

A version of code that is more readable.

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

What is the typeof an ES6 class?

A

A function.

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

What is “refactoring”?

A

Restructuring code to be more efficient and readable but not changing the output.

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

What is a webpack?

A

Webpack is a tool that bundles JavaScript applications, and supports any module format aside from ESM.

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

How do you add a devDependency to a package?

A

From the root directory in the command line, you run npm install with the package-name and the “–save-dev” flag

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

What is an npm script?

A

An npm script bundles commands together, and are typically commands, or a string of commands that would usually be entered in the command line to have an application do something.

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

How do you execute Webpack with npm run?

A

With npm run script-name.

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

What is Babel?

A

Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into compatible versions of JavaScript.

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

What is a plug-in?

A

A software component that adds a specific feature to an existing program.

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

What is a webpack loader?

A

Loaders are transformations that are applied to source code of a module, and provide a way to handle front-end build steps.

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

How can you make Babel and webpack work together?

A

Install the Babel loader then configure the webpack.js file.

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

What is JSX?

A

JSX is a React extension to the JavaScript language syntax.

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

Why must the react object be imported when authoring JSX in a module?

A

To bring the React library in scope with the JSX code.

17
Q

How can you make Webpack and Babel work together to convert JSX into valid JavaScript?

A

You can use a Babel loader

18
Q

What is a React component?

A

React components are JavaScript functions or classes that are reusable pieces of code.

19
Q

How do you define a function component in React?

A

You start with the keyword function, followed by a function name with a (parameter), opening curly brace, then a return react elements. Ending with a curly brace.

20
Q

How do you mount a component to the DOM?

A

Create a react root by calling the createRoot method of the ReactDOM object with the react elements and assigning it to a variable. Then the render method of the root object is called with the function as an argument.

21
Q

What are props in React?

A

Props are objects.

22
Q

How do you pass props to a components?

A

Props are passed to a component thru a DOM tag name and assigning a value to the prop name, then assigning the return value to an element.

23
Q

How do you write JavaScript expressions in JSX?

A

JavaScript expressions are wrote in JSX within a functions’ curly braces.

24
Q

What are controlled components?

A

An input form element whose value is controlled by React.

25
What two props must you pass to an input for it to be "controlled?"
Value and onChange.
26
What array methods is commonly used to create a list of React elements?
The map() method.
27
What is the best value to use as a "key" prop when rendering lists?
A string that identifies the key, or an ID from the data.
28
What is a fetch() return?
A Promise that resolves to a Response object.
29
What is the default request method used by fetch?
A Get request.
30
How do you specify the request method (GET, POST, etc) when calling fetch?
Enter the method into the second row.
31
When does React call a component's componentDidMount method?
Immediately after a component is mounted/inserted into the tree.
32
Name three React.Component lifecycle methods.
Constructor, render, and componentDidMount.
33
How do you pass data to a child component?
Through props.