m3-0822 Flashcards

1
Q

What is Array.prototype.filter useful for?

A

The filter() method creates a shallow copy of a portion of a given array, filtered down to just the elements from the given array that pass the test implemented by the provided function.

useful for getting values from an array that meet the conditions you specify

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

The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.

useful for manipulating each element of an array in the way specified

Creating a new array containing the transformed elements of another.

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

Perhaps the easiest-to-understand case for reduce() is to return the sum of all the elements in an array

run through an array and performing the same operation on each element cumulatively

Combining the elements of an array into a single value.

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

What is “syntactic sugar”?

A

syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express

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

function

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

Describe ES6 class syntax.

A

class keyword, followed by the name of the class
inside the code block, constructor method where you can initialize the properties of an instance and other methods can be added

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

What is “refactoring”?

A

code refactoring is the process of restructuring existing computer code—changing the factoring—without changing its external behavior

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

What is Webpack?

A

It’s a tool that lets you bundle your JavaScript applications (supporting both ESM and CommonJS), and it can be extended to support many different assets such as images, fonts and stylesheets.

Webpack is a helpful tool we use during development to write code that is readable to us but usable by browsers.

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

How do you add a devDependency to a package?

A

npm install –save-dev (name of package)

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

What is an NPM script?

A

way to bundle shell commands

help us run repetitive tasks, automates tasks

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

How do you execute Webpack with npm run?

A

add npm script to package.json named “build” that executes “webpack” and then npm run build in the CLI

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

How are ES Modules different from CommonJS modules?

A

Their syntax is even more compact than CommonJS’s.
Their structure can be statically analyzed (for static checking, optimization, etc.).
Their support for cyclic dependencies is better than CommonJS’s.

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

What kind of modules can Webpack support?

A

ECMAScript modules. CommonJS modules. AMD modules.

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

What is React?

A

A JavaScript library for building user interfaces

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

What is a React element?

A

React Element - It is a simple object that describes a DOM node and its attributes or properties you can say. It is an immutable description object and you can not apply any methods on it.

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

How do you mount a React element to the DOM?

A

calling the render method of the React root object

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

What is Babel?

A

Babel is a JavaScript compiler that converts code to older syntax.

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

What is a Plug-in?

A

a software component that adds a specific feature to an existing computer program

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

What is a Webpack loader?

A

transformations that are applied to the source code of a module

20
Q

How can you make Babel and Webpack work together?

A

using loaders

21
Q

What is JSX?

A

a syntax extension to JavaScript

22
Q

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

A

Since JSX compiles into calls to React.createElement, the React library must also always be in scope from your JSX code.

23
Q

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

A

babel-loader

24
Q

What is a React component?

A

Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.

independent, reusable pieces of the UI

25
Q

How do you define a function component in React?

A

write a JavaScript function

26
Q

How do you mount a component to the DOM?

A

calling the render method of a root object with the component as the argument

27
Q

What are props in React?

A

object that provides data to the React component

28
Q

How do you pass props to a component?

A

through JSX attributes

29
Q

How do you write JavaScript expressions in JSX?

A

{ }

30
Q

How do you create “class” component in React?

A

To define a React component class, you need to extend React.Component.
The only method you must define in a React.Component subclass is called render().

31
Q

How do you access props in a class component?

A

through prototypal inheritance from React.Component

JavaScript expressions

32
Q

What is the purpose of state in React?

A

provide information about the component’s current situation

33
Q

How to you pass an event handler to a React element?

A

inside the opening JSX tag include name of the event in camel case and assign a the callback function from the this object

34
Q

What are controlled components?

A

React components that render a form and also control what happens in that form on subsequent user input

35
Q

What two props must you pass to an input for it to be “controlled”?

A

value and onChange

36
Q

What Array method is commonly used to create a list of React elements?

A

map method

37
Q

What is the best value to use as a “key” prop when rendering lists?

A

The best way to pick a key is to use a string that uniquely identifies a list item among its siblings.

38
Q

What does express.static() return?

A

function

39
Q

What is the local __dirname variable in a Node.js module?

A

the absolute path to the directory name of the current module

40
Q

What does the join() method of Node’s path module do?

A

The path.join() method joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.

41
Q

What does fetch() return?

A

A Promise that resolves to a Response object.

42
Q

What is the default request method used by fetch()?

A

GET request

43
Q

How do you specify the request method (GET, POST, etc.) when calling fetch?

A

method => options

44
Q

When does React call a component’s componentDidMount method?

A

when an instance of a component is being created and inserted into the DOM
(render is called for the first time)

45
Q

Name three React.Component lifecycle methods.

A

render, constructor, componentDidMount, componentDidUpdate, componentWillUnmount

46
Q

How do you pass data to a child component?

A

through the props object