ES6 Flashcards

1
Q

What is a code block? What are some examples of a code block?

A

Code within {}. Examples include - functions, loops, conditionals. For loop (let i = 0; i < length; i++) is part of the following block.

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

What does block scope mean?

A

It means that a variable is not attached to the global window object and is only referenced inside the current code block.
What happens inside the code block, stays inside the code block.

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

What is the scope of a variable declared with const or let?

A

IT IS BLOCK SCOPE. It depends where it is declared, either inside a code block making it block scoped or outside. Allows using the same variable name with the let keyword outside a code block and reusing it with a second let keyword inside a code block.

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

What is the difference between let and const?

A

The difference is that let can be reassigned but const cannot be reassigned.

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

Why is it possible to .push() a new value into a const variable that points to an Array?

A

.push is not reassignment of a new array, only changing/mutating the original array.

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

How should you decide on which type of declaration to use?

A

Start with const, till the linter/compiler gets mad. Const should be used if no reassignment is needed. Let should be used if the variable will change throughout the code file.

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

What is the syntax for writing a template literal?

A

Backticks with ${} to denote substitutions.

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

What is “string interpolation”?

A

Concatenating strings and string substitutions.

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

What is destructuring, conceptually?

A

Pulling individual values from objects and arrays and assigning them to a variable.

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

What is the syntax for Object destructuring?

A

const { property: variableName } = original object
don’t need variable name if using property name for the variable name.

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

What is the syntax for Array destructuring?

A

Using brackets with the variables in the position of the array you want, assigned to the array.
const [a, , b] = array

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

How can you tell the difference between destructuring and creating Object/Array literals?

A

The side of the equal sign which the curly braces or brackets come on.

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

What is the syntax for defining an arrow function?

A

params or () => single line implied return declaration.
params or () => { code }

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

When an arrow function’s body is left without curly braces, what changes in its functionality?

A

It implies a return statement of one expression only.

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

What is a CLI?

A

Command line interface - usually called the console or terminal

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

What is a GUI?

A

A graphical user interface, most common for users, VS code is a GUI for coders, that also contains a CLI.

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

Give at least one use case for each of the commands listed in this exercise.
man
cat
ls
pwd
echo
touch
mkdir
mv
rm
cp
history

A

man -open a manual of a cmd
cat - print contents of a file
ls - ls files and directories
pwd - prints the current or working directory
echo - logs a string
touch - move a file - change timestamp
mkdir - make a new directory
mv - rename files or move
rm - remove files
cp - copy files
history - prints cmd line history

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

What are the three virtues of a great programmer?

A

hubris, impatience, laziness

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

What are the 3 components of a fullstack Web architecture?

A

frontend(presentation), backend server(logic handling), database

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

What is Node.js?

A

Allows JavaScript to be run outside of a browser.

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

What can Node.js be used for?

A

to build servers and other automation in command line programs.

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

What is a REPL?

A

A Read-eval-print loop. The part that allows you to run JavaScript code, like our developer tools in our browser.

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

When was Node.js created?

A
  1. may 27
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What backend languages have you heard of?

A

express, Node, PHP, RUBY, C++, Java, C#

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

What is a computer process?

A

executable task

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

Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?

A

290

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

Why should a full stack Web developer know that computer processes exist?

A

Processes run our code.

28
Q

What is the process object in a Node.js program?

A

It is a global object, like the window object in developers tools and contains many properties and methods and event listeners.

29
Q

How do you access the process object in a Node.js program?

A

As process? or process.property

30
Q

What is the data type of process.argv in Node.js?

A

process.argv is an array of strings with the first 2 index representing the directory/file locations?

31
Q

How do you access the command line arguments in a Node.js program?

A

You can access the indexes of the process.argv of index 2+ depending on your arguments.
I.E.
node file.name argument1 argumentN
Will pass those arguments into the js file and can be retrieved with process.argv[2] and process.argv[3]. Potentially going to pass the return of another file as arguments to another file? Would have to be json.

32
Q

What is a JavaScript module?

A

A JavaScript file.

33
Q

What are the advantages of modular programming?

A

You can separate functionality and keep code cleaner and easier to read.

34
Q

In JavaScript, how do you make a function in a module available to other modules?

A

Export functions with the export keyword, only one can be export default.

35
Q

In JavaScript, how do you use a function from another module?

A

You can import functions with the import keyword.

36
Q

What is the JavaScript Event Loop?

A

It’s a place where code goes to wait to be called back onto the ‘stack’ when the stack is empty.

37
Q

What is different between “blocking” and “non-blocking” with respect to how code is executed?

A

Blocking stops other code from running(single-threaded), where in non-blocking code is put onto a que when it can run.

38
Q

What does Array.filter do?

A

Creates a new array from an array based on a condition.

39
Q

What should the callback function return?

A

Boolean, whether or not to keep the array.

40
Q

What is Array.filter useful for?

A

Removing unwanted values from an array.

41
Q

What does Array.map do?

A

Manipulates every element in an array and returns it as a new array.

42
Q

What should the callback function return?

A

Return, a value of the manipulated element.

43
Q

What is Array.map useful for?

A

Doing one thing to all elements of an array. Remember for React.

44
Q

What does Array.reduce do?

A

Combines all the elements of an array, in a particular way to a single value.

45
Q

What action should the callback function perform?

A

Perform an expression on the current value to combine with the accumulated value.

46
Q

What should the callback function return?

A

Should return the accumulated value.

47
Q

What is Array.reduce useful for?

A

Turning an array into one value.

48
Q

What is a directory?

A

A file folder.

49
Q

What is a relative file path?

A

The location of a file based on another file.

50
Q

What is an absolute file path?

A

The full path location of a file based on the root. /<– starts a absolute

51
Q

What module does Node.js include for manipulating the file system?

A

node fs, which is node File System.

52
Q

What method is available in the node:fs module for reading data from a file?

A

fs.readfile

53
Q

What method is available in the node:fs module for writing data to a file?

A

The writefile method of the fs object.

54
Q

Are file operations using the fs module synchronous or asynchronous?

A

They are asynchronus. The promise one is better.

55
Q

What are JavaScript classes?

A

They define a particular group of objects. Template.

56
Q

When would you want to use a class?

A

When you have multiple objects with similar properties and methods.

57
Q

When would you want to use a class?

A

When you have multiple objects with similar properties and methods.

58
Q

How do you declare a class?

A

With the class keyword followed by the class’s name. A constructor code block.

59
Q

How do you inherit from another class?

A

Using the extends keyword. And calling super() in the constructor.

60
Q

Why would you want to inherit from another class?

A

Your object shares the same properties and methods of this class plus more.

61
Q

How do you add methods and properties to a class?

A

You add properties in it’s constructor body and then declare methods after.

62
Q

What does fetch() return?

A

A promise which will be a response object.

63
Q

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

A

GET

64
Q

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

A

pass a request object to the options argument.

65
Q

How does fetch report errors?

A