Module 3 Flashcards

1
Q

What is Array.prototype.filter useful for?

A

for finding values in an array

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

for applying a function to every value of 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

applying a function to and compile all values in 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

a way to increase code readability, but does not increase functionality

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 \_\_className\_\_ {
    constructor (\_\_para1\_\_, \_\_para2\_\_) {
 this.\_\_prop1\_\_ = \_\_\_\_;
this.\_\_prop2\_\_ = \_\_\_\_;
}
\_\_method1\_\_() {}
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is “refactoring”?

A

refactoring is the reorganization of code to increase efficiency without changing the functionality

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

What is Webpack?

A

a program that compiles JS files and uses immediately invoked function expressions (IIFE) to run the JS modules

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

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

What is an NPM script?

A

a package of pre-written code that you can import and use in your code

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

use npm install –save-dev webpack

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

they use ‘import’ and ‘export’ statements to reference other modules vs ‘require’ and ‘module.exports’ statements; standardized module import/export syntax for use with bundlers

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, CommonJS, AMD

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

What is React?

A

a framework that allows components to update w/out reloading the page

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

What is a React element?

A

an object that describes a component instance or DOM node and its desired properties; not an HTML element, just contains info about a component

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

ReactDOM.render()

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

What is Babel?

A

a toolkit that converts source code into a backward compatible version

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

What is a Plug-in?

A

a downloadable add-in that adds a feature to an existing piece of software

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

What is a Webpack loader?

A

an add-in that pre-processes code as modules are compiled

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

How can you make Babel and Webpack work together?

A

using the babel-loader

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

What is JSX?

A

an html-like syntax that gets converted to react elements

22
Q

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

A

because JSX compiles calls into React.createElement()

23
Q

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

A

using the Babel plugin transform-react-jsx

24
Q

What is a React component?

A

JS functions that return React elements

25
Q

How do you define a function component in React?

A

like a normal JS function; use capital letter for funct name

26
Q

How do you mount a component to the DOM?

A

ReactDOM.render(element, htmlComponent)

27
Q

What are props in React?

A

obj that passes info to React components; a way to get outside info into component; key:value pair in JSX gets added to props

28
Q

How do you pass props to a component?

A

add it as an attribute (key:value pair) to the component call

29
Q

How do you write JavaScript expressions in JSX?

A

within {}

30
Q

How do you create “class” component in React?

A
by using "class \_\_className\_\_ extends React.Component{
render() {}
}"
31
Q

How do you access props in a class component?

A

this.props

32
Q

What is the purpose of state in React?

A

allows us to control what is displayed by updating based on changes to state

33
Q

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

A

as an attribute; < __JSX elm__ __eventHandler__ = __callback__ >

34
Q

What are controlled components?

A

whose value and route of submittal is controlled by this.state

35
Q

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

A

value={this.state.__value__} and onChange event handler

36
Q

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

A

37
Q

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

A

38
Q

What does express.static() return?

A

function

39
Q

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

A

the directory that the node module is running in; folder that the file __dirname is in

40
Q

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

A

concatenates path names

41
Q

What does fetch() return?

A

a Promise

42
Q

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

A

GET

43
Q

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

A

in the init obj; using ‘method’ prop

44
Q

When does React call a component’s componentDidMount method?

A

runs after the component mounts on the DOM; ONLY called after the first render

45
Q

Name three React.Component lifecycle methods.

A

componentDidMount, componentWillUnMount, componentDidUpdate

46
Q

How do you pass data to a child component?

A

props

47
Q

What must the return value of myFunction be if the following expression is possible?
myFunction()()

A

-

48
Q
What does this code do?
const wrap = value => () => value;
A

-

49
Q

In JavaScript, when is a function’s scope determined; when it is called or when it is defined?

A

-

50
Q

What allows JavaScript functions to “remember” values from their surroundings?

A