ES6 Flashcards
What is a code block? What are some examples of a code block?
code written inside the bracket {}
function bodys
loops
conditional
What does block scope mean?
something only existing inside the block
What is the scope of a variable declared with const or let?
block scope
What is the difference between let and const?
let variable can be reassigned const cant be reassigned
Why is it possible to .push() a new value into a const variable that points to an Array?
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
What is the syntax for writing a template literal?
` `
What is the syntax for writing a template literal?
${expression}
What is “string interpolation”?
the ability to substitute part of the string for the values of variables or expressions.
What is destructuring conceptually?
takes values from arrays, or properties from objects, into distinct variables.
What is the syntax for Object destructuring?
const or let {propertyname} = object
What is the syntax for Array destructuring?
const or let or var [variable name ] = array
How can you tell the difference between destructuring and creating Object/Array literals?
if the array or object is on the left side then it destructuring
What is the syntax for defining an arrow function?
var keyword function = arguements => expresion let func = (arg1, arg2, ..., argN) => expression
When an arrow function’s body is left without curly braces, what changes in its functionality?
you can only have 1 line of code no curly braces no return keyword and it has to be an expression
How is the value of this determined within an arrow function?
based on the code block where the method is called
this is determined by call time based on its parents cod block
What is a CLI?
command line interface
What is a GUI?
graphical line interface
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
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
What are the three virtues of a great programmer?
laziness, impatience, and hubris.
What is Node.js?
a program that allows JavaScript in to be run outside of a web browser
What can Node.js be used for?
To build back ends for Web applications, command-line programs or any automation for devs to use
What is a REPL?
It is a quick and easy way to test simple Node.js/JavaScript code
When was Node.js created?
May 27, 2009
What back end languages have you heard of?
C# Java JS C++ Go VBA PHP Ruby Python Rust Haskell Pascal Perl Lisp C Clojure Rust Objective-C Swift Kotlin Julia Haskell Pas
What is a computer process?
The instance of a computer program that is being executed by one or many threads
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
more than 100
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
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
How do you access the process object in a Node.js program?
just call it its global
What is the data type of process.argv in Node.js?
array of strings
What is a JavaScript module?
a “module” is a single .js file
What values are passed into a Node.js module’s local scope?
filename dirname module require and exports
Give two examples of truly global variables in a Node.js program.
process
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
How do you import functionality into a Node.js module from another Node.js module?
call the require and use the correct file path
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
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
What is a directory?
a collection of files typically created for organizational purposes
What is a relative file path?
refers to a location that is relative to a current directory
What is an absolute file path?
path always contains the root element and the complete directory list required to locate the file
What module does Node.js include for manipulating the file system?
fs module
What method is available in the Node.js fs module for writing data to a file?
writefile
Are file operations using the fs module synchronous or asynchronous?
fs module are both synchronous and asynchronus
What is NPM?
NPM is a software registry. Where developers can share and borrow reusable code. it can mean the website cli registry
What is a package?
A file or directory that is describes by a package.json
How can you create a package.json with npm?
inside the root directory run the command
npm init –yes
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
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
How do you add express to your package dependencies?
npm install express adds to package.json
What Express application method starts the server and binds it to a network PORT?
listen()
What is a client?
Requests a service made available by a server
What is a server?
Provides the services that the client requests
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
What is on the first line of an HTTP request message?
The HTTP method like (GET, POST, AND PUT)
What is on the first line of an HTTP response message?
The protocol version
What are HTTP headers?
Let the client and the server pass additional information with an HTTP request or response.