ES6 Flashcards

1
Q

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

A

the code inside of curly braces {}

function code block, conditionals, etc

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

What does block scope mean?

A

The variables are only attached to what’s inside of the block, they do not attach to the global object (the window object)

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

Const and Let are block-scoped - cannot be accessed outside particular 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

let can have its value reassigned, const cannot have its value 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 reassigning or redeclaring the variable, it is simply adding to the array

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

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

A

Use const by default unless the variable’s value will need to change

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

use backticks `` and use ${variable}

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

What is “string interpolation”?

A

the ability to substitute part of a string for the values of variables or expression

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

What is destructuring, conceptually?

A

Taking data out of either an object or an array and assigning it to individual variables

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 {propertyName: variable1, propertyName2: variable2; etc…} = objectName

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

Const [variablename1, variablename2, variablename3, etc] = arrayName

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

Curly Braces vs square brackets

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

Parameters => expression

Const fnName = (Parameters) => {codeblock with return}

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

You can only put one expression to the right of the arrow, has an implicit return, result of that expression is returned

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

How is the value of this determined within an arrow function?

A

Has lexical scoping to this context

Value of this is defined at definition

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

What is a CLI?

A

Command Line Interface - connects user to a computer program or OS
Text based interface that runs programs, manage computer files and interacts with computer

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

What is a GUI?

A

Graphical User Interface - computer programs that provide a visual means for users to interact with an underlying application or system.

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

Give at least one use case for each of the commands listed in this exercise.

A

Man - manual, view the manual of the certain command
Cat - outputs content of the file or concat files together
Ls - lists directory contents
Pwd - display path of current working file(where am i?)
Echo -displays line of text within CLI(console.log for terminal)
Touch - update file access , modify time and create file if one does not exist
Mkdir - make a directory
Mv - move(rename) files (files name is its location)
Rm - remove(delete) directory -f is force delete
Cp - copy file or directory, can override an existing file

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

What are the three virtues of a great programmers?

A

Laziness, Impatience, Hubris

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

What is Node.JS?

A

Open source, cross platform runtime environment that allows developers to create all kinds of server-side tools and applications in javascript. Allow users to run javascript outside of the 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

Node. js is primarily used for non-blocking, event-driven servers, due to its single-threaded nature. It’s used for traditional web sites and back-end API services, but was designed with real-time, push-based architectures in mind.

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

What is a REPL?

A

Read Eval Print Loop - takes user inputs, executes them and returns to user

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

When was Node.js created?

A

May 27, 2009

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

What back end languages have you heard of?

A

python , node, php, javascript, ruby, java, GoLang, C#

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

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

A

It’s a global that provides information about, and control over, the current Node.js process.

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

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

A

As a global, it is always available to Node.js applications without using require(). It can also be explicitly accessed using require()

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

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

A

Object

Array of strings

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

What is a JavaScript module?

A

Single .js file , each provide its own chunk of functionality

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

What values are passed into a Node.js module’s local scope?

A

exports, require, module, __filename, __dirname

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

Give two examples of truly global variables in a Node.js program.

A

Process and global

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

What is the purpose of module.exports in a Node.js module?

A

Be able to export code into another module

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

How do you import functionality into a Node.js module from another Node.js module?

A

require() and pass in the relative path of the file as a string argument

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

What is the JavaScript Event Loop?

A

responsible for executing the code, collecting and processing events, and executing queued sub-tasks

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

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

A

Fast vs slow code, prevents us from continuing the code and we can only proceed once the code block has been executed

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

What is a directory?

A

File system structure which contains references to other files and possibly other directories

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

What is a relative file path?

A

Location of file using current directory as a reference, uses current or parent directory as reference to specify path relative to it.

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

What is an absolute file path?

A

Specific location in a file system not related to current directory, specify location from root directory (/)

38
Q

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

A

Fs module

39
Q

What method is available in the Node.js fs module for writing data to a file?

A

fs.writeFile()

40
Q

Are file operations using the fs module synchronous or asynchronous?

A

yes

41
Q

What is a client?

A

Someone who requests a service, browser and http pie

42
Q

What is a server?

A

Program or device that receives requests from client and sends back data

43
Q

Which HTTP method does a browser issue to a web server when you visit a URL?

A

`GET

44
Q

What is on the first line of an HTTP request message?

A

HTTP method; a verb or noun that describes action being performed
The target request: either a URL or absolute path of the protocol, port, and domain are usually characterized by the request context.
HTTP version that is being used

45
Q

What is on the first line of an HTTP response message?

A

Protocol version: http version
Status code: example 404
Status text: text description of the status code to help humans understand http message

46
Q

What are HTTP headers?

A

Meta deta from the http request

47
Q

Is a body required for a valid HTTP message?

A

No

48
Q

What is NPM?

A
Node package manager, open source , world’s largest software registry, allows developers to share and borrow packages. 
Consists of three things:
The website
The CLI
The registry
49
Q

What is a package?

A

file or directory that is described by a package.json file. (must have this file).

all the files you need for a module

50
Q

How can you create a package.json with npm?

A

npm init -yes

51
Q

What is a dependency and how do you add one to a package?

A

packages required by your application

add by npm install (package name)

52
Q

What happens when you add a dependency to a package with npm?

A

It adds library to json Object

53
Q

How do you add express to your package dependencies?

A

create new project, npm init -yes

npm install express

verify it in the JSON object

54
Q

What Express application method starts the server and binds it to a network port?

A

LISTEN

55
Q

How do you mount a middleware with an express application?

A

USE

56
Q

Which objects does an Express application pass to your middleware to manage?

A

req and res objects (Request and Response)

57
Q

What is the appropriate CONTENT-TYPE header for HTTP messages to contain JSON in their bodies?

A

application/JSON

58
Q

What does the express.json() middleware do and when would you need it?

A

parses incoming request with json payload and is based on body-parser. Where is the actual data? BODY!!!! (header/blank line/body) —> it looks for the json data in the body. Will send empty object if the JSON wasn’t sent correctly.

59
Q

What is the significance of an HTTP request’s method?

A

HTTP defines a set of request methods to indicate the desired action to be performed for a given resource.

60
Q

What are the three states a promise can be in ?

A

Pending: initial state
Fulfilled: meaning that the operation was successful
Rejected: operation failed

61
Q

How do you handle the fulfillment of a Promise?

A

THEN method

62
Q

How do you handle the rejection of a Promise?

A

CATCH method

63
Q

What is Array.Prototype.Filter useful for?

A

Sort elements out of array with certain conditions

64
Q

What is Array.Prototype.Map useful for?

A

Creates new array populated with the results of calling a provided function on every element in the calling array.

65
Q

What is Array.prototype.Reduce useful for?

A

The reduce() method executes a user-supplied “reducer” callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.

66
Q

What is “syntactic sugar”?

A

Changing the syntax to make it easier to read or express

67
Q

What is the typeOf an ES6 class?

A

FUNCTION

68
Q

Describe the ES6 class syntax

A
class keyword nameOfClass{
constructor keyword(parameters){
    }
}
69
Q

What is “refactoring”?

A

The process of restructuring existing computer code without changing or adding to its external behavior or functionality.

70
Q

What is Webpack?

A

This is why webpack exists. 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. Node js to bundle everything

71
Q

How do you add a devDependency to a package?

A

–save-dev

72
Q

What is an NPM Script?

A

Set of built-in and custom functions defined within the package.json file that all you to do certain things within your application

73
Q

How do you execute webpack with npm run?

A

npm run

74
Q

How are ES Modules different from CommonJS modules?

A

Their syntax is more compact
Their structure cam be statically analyzed
Their support for cyclic dependencies is better than CommonJSs
Specific keywords in ES , common JS calls functions

75
Q

What kind of modules can Webpack support?

A

ECMAScript Modules, CommonJS, AMD Modules

76
Q

What does fetch() return?

A

Returns a promise that resolves with a RESPONSE object
Doesnt contain actual JSON response body, but instead a representation of the entire http response.
Use the json() method which returns a second promise that resolves with the result of parsing the response body text as JSON

77
Q

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

A

GET method

78
Q

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

A

Create a new request and in the second argument create an object literal with a method property with the value being whatever method you would like to use

79
Q

What does express.static() return?

A

Returns ServeStatic function

Create a new middleware function to serve files from within a given root directory

80
Q

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

A

Absolute path of the directory name

81
Q

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

A

Joins all the paths together into a single path string by puting slash between each

82
Q

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

A

myFunction()();

Must return another function

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

function that takes single param, and then there is a function that takes no params, and it returns the outter params.

84
Q

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

A

At definition

85
Q

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

A

closures

86
Q

What does the acronym LIFO mean?

A

Last In First Out

87
Q

What methods are available on a Stack data structure?

A

push(value), pop()

88
Q

What must you do to access the value at an arbitrary point in a stack (not just the “top”)?

A

peek()

89
Q

What does the acronym FIFO mean?

A

First In First Out

90
Q

What methods are available on a Queue data structure?

A