ES6 Flashcards

1
Q

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

A

code written inside the bracket {}
function bodys
loops
conditional

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

What does block scope mean?

A

something only existing inside the 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

block scope

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 variable can be reassigned const cant 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

the const variable, in this case, an array, itself is immutable; on the other hand, the array itself is mutable - meaning, you can add new things to the array; think reassignment

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

What is the syntax for writing a template literal?

A

` `

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

${expression}

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 the string for the values of variables or expressions.

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

What is destructuring conceptually?

A

takes values from arrays, or properties from objects, into distinct 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 or let {propertyname} = object

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 or let or var [variable name ] = 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

if the array or object is on the left side then it destructuring

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
var keyword function  = arguements => expresion
let func = (arg1, arg2, ..., argN) => expression
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 have 1 line of code no curly braces no return keyword and it has to be an expression

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

based on the code block where the method is called

this is determined by call time based on its parents cod block

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

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

What is a GUI?

A

graphical line interface

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.
man
cat
ls
pwd
echo
touch
mkdir
mv
rm
cp
A

man is the manual
cat is when you want to add more than 1 file together
ls list directory contents
pwd returns working directory name
echo write arguments to the standard output
touch changes file access and modification times
mkdir makes directories
mv moves files or renames
rm removes files
cp makes a copy of the files

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 programmer?

A

laziness, impatience, and hubris.

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

What is Node.js?

A

a program that allows JavaScript in to be run outside of a web 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 back ends for Web applications, command-line programs or any automation for devs to use

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

What is a REPL?

A

It is a quick and easy way to test simple Node.js/JavaScript code

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

C# Java JS C++ Go VBA PHP Ruby Python Rust Haskell Pascal Perl Lisp C Clojure Rust Objective-C Swift Kotlin Julia Haskell Pas

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is a computer process?
The instance of a computer program that is being executed by one or many threads
26
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
more than 100
27
Why should a full stack Web developer know that computer processes exist?
they should know how processes are working together to make an application work
28
What is the process object in a Node.js program?
is a global that provides information about, and control over, the current Node.js process
29
How do you access the process object in a Node.js program?
just call it its global
30
What is the data type of process.argv in Node.js?
array of strings
31
What is a JavaScript module?
a "module" is a single .js file
32
What values are passed into a Node.js module's local scope?
filename dirname module require and exports
33
Give two examples of truly global variables in a Node.js program.
process
34
What is the purpose of module.exports in a Node.js module?
the instruction that tells Node. js which bits of code (functions, objects, strings, etc.) to “export” from a given file so other files are allowed to access the exported code
35
How do you import functionality into a Node.js module from another Node.js module?
call the require and use the correct file path
36
What is the JavaScript Event Loop?
Cycles through the call stack and checks if theres anything in the task queue and pushes that to the task queue
37
What is different between "blocking" and "non-blocking" with respect to how code is executed?
blocking is execution must wait till other code is completed none blocking doesnt block the code from being executed
38
What is a directory?
a collection of files typically created for organizational purposes
39
What is a relative file path?
refers to a location that is relative to a current directory
40
What is an absolute file path?
path always contains the root element and the complete directory list required to locate the file
41
What module does Node.js include for manipulating the file system?
fs module
42
What method is available in the Node.js fs module for writing data to a file?
writefile
43
Are file operations using the fs module synchronous or asynchronous?
fs module are both synchronous and asynchronus
44
What is NPM?
NPM is a software registry. Where developers can share and borrow reusable code. it can mean the website cli registry
45
What is a package?
A file or directory that is describes by a package.json
46
How can you create a package.json with npm?
inside the root directory run the command | npm init --yes
47
What is a dependency and how to you add one to a package?
Packages required by your application in production. You can add dependencies to a package.json file from the command line or by manually editing the package.json file npm install name of pacakge
48
What happens when you add a dependency to a package with npm?
npm add dependencies to to package.json theres a node module directory created as well
49
How do you add express to your package dependencies?
npm install express adds to package.json
50
What Express application method starts the server and binds it to a network PORT?
listen()
51
What is a client?
Requests a service made available by a server
52
What is a server?
Provides the services that the client requests
53
Which HTTP method does a browser issue to a web server when you visit a URL?Which HTTP method does a browser issue to a web server when you visit a URL?
GET
54
What is on the first line of an HTTP request message?
The HTTP method like (GET, POST, AND PUT)
55
What is on the first line of an HTTP response message?
The protocol version
56
What are HTTP headers?
Let the client and the server pass additional information with an HTTP request or response.
57
Is a body required for a valid HTTP message?
No
58
How do you mount a middleware with an Express application?
use()
59
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
request object and response object
60
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
61
What does the express.json() middleware do and when would you need it?
parses incoming json body from ,we will need it
62
What is PostgreSQL and what are some alternative relational databases?
Free, open source Relational Database Management System (RDBMS). Microsoft SQL. MySQL. Oracle Database IBM Db2 SAP HANA Amazon Relational Database Service (RDS) SQLite MariaDB
63
What are some advantages of learning a relational database?
Data Accuracy Easy Access to Data They are used everywhere
64
What is one way to see if PostgreSQL is running?
sudo service postgresql status
65
What is a database schema?
A collection of tables. It defines how the data in a relational database should be organized
66
What is a table?
A table is a list of rows each having the same set of attributes
67
What is a row?
set of related data
68
What is SQL and how is it different from languages like JavaScript?
SQL is the most common language for extracting and organizing data that is stored in a relational database. SQL is declarative programming where you can describe the results and imperative programming like JS youre on charge on have to write specific ways on how to get there
69
How do you retrieve specific columns from a database table?
use select clause followed by the column you want | select "column"
70
How do you filter rows based on some specific criteria?
use clause where followed what you want filtered and assign and operator of what you want it filtered by where "column" = 'false';
71
What are the benefits of formatting your SQL?
makes the code more easier to read and understand making it more efficient
72
How do you limit the number of rows returned in a result set?
use limit keyword followed by number you want to limit
73
How do you limit the number of rows returned in a result set?
use limit clause followed by number you want to limit
74
How do you retrieve all columns from a database table?
use * on select clause | select *
75
How do you control the sort order of a result set?
use desc or asc on clause order by | order by "column desc
76
How do you add a row to a SQL table?
insert into clause insert into "products" ("name", "description", "price", "category") values ('Ostrich Pillow', 'Feel comfy and cozy!', 99, 'self care')
77
What is a tuple?
group of values in the parenthesis
78
How do you add multiple rows to a SQL table at once?
use values keyword then comma to seperate
79
How do you get back the row being inserted into a table without a separate select statement?
before you end with semicolon use returning clause with an *
80
How do you update rows in a database table?
update clause followed by the table name set clause column name and assigning the new value update "products" set "price" = 100;
81
Why is it important to include a where clause in your update statements?
to get specific rows you want to updated if not they will all be updated
82
How do you delete rows from a database table?
delete from clause then the table
83
How do you accidentally delete all rows from a table?
if you omit the where clause itll delete all rows delete from "products" where "productId" = 24
84
What is a foreign key?
shared attributes in tables
85
How do you join two SQL tables?
join "name of table" using ("column name")
86
What are some examples of aggregate functions?
MIN, MAX, AVG, SUM, and COUNT.
87
What is the purpose of a group by clause?
used to group rows that have the same values
88
What are the three states a Promise can be in?
pending: initial state, neither fulfilled nor rejected. fulfilled: meaning that the operation was completed successfully. rejected: meaning that the operation failed.
89
How do you handle the fulfillment of a Promise?
.then(callback)
90
How do you handle the rejection of a Promise?
.catch(callback)
91
How do you handle the rejection of a Promise?
.catch(callback)
92
What is Array.prototype.filter useful for?
to give you back elements in an array that you specify for
93
What is Array.prototype.map useful for?
transform each element of an array and put the new transformation into a new array
94
What is "syntactic sugar"?
Syntax within a programming language that is designed to make things easier to read or to express.
95
What is the typeof an ES6 class?
function
96
Describe ES6 class syntax.
``` class "name"{ constructor(a,b,c,d){ this.a =a this.b = b this.c = c } more methods } ```
97
What is "refactoring"?
altering its internal structure without changing its external behavior.
98
What is "refactoring"?
altering its internal structure without changing its external behavior.
99
What is Webpack?
takes all modules in your main js and puts them all together and uses it
100
How do you add a devDependency to a package?
npm install --save-dev 'name of package'
101
What is an NPM script?
allows you to define script commands using the scripts field in the package.json file.
102
How do you execute Webpack with npm run?
check if command is in the script and run the name of the property
103
How are ES Modules different from CommonJS modules?
es6 modules statically called, commonjs are dynamic,commonjs use module.exports property
104
What kind of modules can Webpack support?
ECMAScript modules. CommonJS modules. AMD modules.
105
What is React?
React is a JavaScript library for creating user interfaces.
106
What is a React element?
an object what gets returned from components
107
How do you mount a React element to the DOM?
ReactDOM.render(element, container[, callback])
108
What is Babel?
Convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments
109
What is a Plug-in?
Software component that adds a specific feature to an existing computer program.
110
What is a Webpack loader?
transformation that is applied to the the source code of a module
111
How can you make Babel and Webpack work together?
npm install --save-dev babel-loader
112
What is JSX?
a syntax extension to JavaScript
113
Why must the React object be imported when authoring JSX in a module?
you need to import react so that the complied output could call the create element
114
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
webpack will take plain js and bundle it together babel plugin
115
What is a React component?
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation
116
How do you define a function component in React?
function and capitalize name with parameters if there is and it has to return a react element
117
How do you mount a component to the DOM?
render dom method and mount elements
118
What are props in React?
its object of arguments passed into React components
119
How do you write JavaScript expressions in JSX?
you have to surround the JavaScript code in { } brackets
120
How do you pass props to a component?
react element attribute and assign a string or a js expression
121
How do you create "class" component in React?
``` class key word name of funciton extends component property render function ex.(class CustomButton extends React.Component { render() { return {this.props.text}; } ```
122
How do you access props in a class component?
with "this" object
123
What is the purpose of state in React?
to represent info of the component current state
124
How to you pass an event handler to a React element?
the property onclick{function}
125
What Array method is commonly used to create a list of React elements?
map()
126
What is the best value to use as a "key" prop when rendering lists?
To use a string that uniquely identifies a list item among its siblings
127
What are controlled components?
elements whose value is controlled by React
128
What two props must you pass to an input for it to be "controlled"?
value and onchange
129
What does express.static() return?
middleware function that returns an object
130
What is the local __dirname variable in a Node.js module?
the file path
131
What does the join() method of Node's path module do?
joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path
132
What does fetch() return?
a promise for a response
133
What is the default request method used by fetch()?
get request
134
How do you specify the request method (GET, POST, etc.) when calling fetch?
init object 2nd parameter fetch('/some-url, method: "trace") call what method and what put what ever method you want
135
When does React call a component's componentDidMount method?
after the component gets mounted on the DOM
136
Name three React.Component lifecycle methods.
Mounting, Updating and Unmounting.
137
How do you pass data to a child component?
through the props
138
What must the return value of myFunction be if the following expression is possible? myFunction()();
Return value has to be a function definition.
139
``` What does this code do? const wrap = value => () => value; ```
Returns a function that returns value.
140
In JavaScript, when is a function's scope determined; when it is called or when it is defined?
when its defined
141
What allows JavaScript functions to "remember" values from their surroundings?
closure