ES6 Flashcards
What is a code block? What are some examples of a code block?
the code inside of curly braces {}
function code block, conditionals, etc
What does block scope mean?
The variables are only attached to what’s inside of the block, they do not attach to the global object (the window object)
What is the scope of a variable declared with const or let?
Const and Let are block-scoped - cannot be accessed outside particular block
What is the difference between let and const?
let can have its value reassigned, const cannot have its value reassigned.
Why is it possible to .push() a new value into a const variable that points to an Array?
.push is not reassigning or redeclaring the variable, it is simply adding to the array
How should have you decide on which type of declaration to use?
Use const by default unless the variable’s value will need to change
What is the syntax for writing a template literal?
use backticks `` and use ${variable}
What is “string interpolation”?
the ability to substitute part of a string for the values of variables or expression
What is destructuring, conceptually?
Taking data out of either an object or an array and assigning it to individual variables
What is the syntax for Object destructuring?
Const {propertyName: variable1, propertyName2: variable2; etc…} = objectName
What is the syntax for Array destructuring?
Const [variablename1, variablename2, variablename3, etc] = arrayName
How can you tell the difference between destructuring and creating Object/Array literals?
Curly Braces vs square brackets
What is the syntax for defining an arrow function?
Parameters => expression
Const fnName = (Parameters) => {codeblock with return}
When an arrow function’s body is left without curly braces, what changes in its functionality?
You can only put one expression to the right of the arrow, has an implicit return, result of that expression is returned
How is the value of this determined within an arrow function?
Has lexical scoping to this context
Value of this is defined at definition
What is a CLI?
Command Line Interface - connects user to a computer program or OS
Text based interface that runs programs, manage computer files and interacts with computer
What is a GUI?
Graphical User Interface - computer programs that provide a visual means for users to interact with an underlying application or system.
Give at least one use case for each of the commands listed in this exercise.
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
What are the three virtues of a great programmers?
Laziness, Impatience, Hubris
What is Node.JS?
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
What can Node.js be used for?
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.
What is a REPL?
Read Eval Print Loop - takes user inputs, executes them and returns to user
When was Node.js created?
May 27, 2009
What back end languages have you heard of?
python , node, php, javascript, ruby, java, GoLang, C#
What is the process object in a Node.js program?
It’s 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?
As a global, it is always available to Node.js applications without using require(). It can also be explicitly accessed using require()
What is the data type of process.argv in Node.js?
Object
Array of strings
What is a JavaScript module?
Single .js file , each provide its own chunk of functionality
What values are passed into a Node.js module’s local scope?
exports, require, module, __filename, __dirname
Give two examples of truly global variables in a Node.js program.
Process and global
What is the purpose of module.exports in a Node.js module?
Be able to export code into another module
How do you import functionality into a Node.js module from another Node.js module?
require() and pass in the relative path of the file as a string argument
What is the JavaScript Event Loop?
responsible for executing the code, collecting and processing events, and executing queued sub-tasks
What is the difference between “blocking” and “non-blocking” with respect to how code is executed?
Fast vs slow code, prevents us from continuing the code and we can only proceed once the code block has been executed
What is a directory?
File system structure which contains references to other files and possibly other directories
What is a relative file path?
Location of file using current directory as a reference, uses current or parent directory as reference to specify path relative to it.