ES6, Node.js Flashcards
What is a code block? What are some examples of a code block?
Statements to be executed and it’s denoted by curly braces. For example, if-else statements, for, and while loop things.
What does block scope mean?
Something that you can’t use outside of the code block because it only exists in the curly braces code block.
What is the scope of a variable declared with const or let?
The block scope. Opposed to function scope (var).
What is the difference between let and const?
The variables declared by the let keyword are mutable therefore you can change their values anytime. But the const keyword can’t be reassigned.
Why is it possible to .push() a new value into a const variable that points to an Array?
Because the array value is mutable but the const value is immutable.
How should you decide on which type of declaration to use?
Use let and const only instead of the var keyword. Use let if the declared value needs to be reassigned and use const if it doesn’t.
What is the syntax for writing a template literal?
Put the backticks on the start and end. And dollar signs with a curly brace and the name of the variable can embed the variables and expressions.
What is “string interpolation”?
It’s the ability to substitute part of the string for the values of variables or expressions.
What is destructuring, conceptually?
It unpacks the values from arrays or properties from objects and is able to reassign them to the new variable.
What is the syntax for Object destructuring?
Start with the variable declaration keyword, followed by the opening curly braces. Inside of the curly braces, put the property name by itself or property name colon with any name that you want to assign, closing the curly brace and equal sign with the original object name.
What is the syntax for Array destructuring?
Start with the variable declaration keyword, followed by the opening square bracket including the names of the new variable of the indexes, followed by the closing square bracket and equal sign with the original array name.
How can you tell the difference between destructuring and creating Object / Array literals?
When creating the object or array literals, it starts with the variable declaration keyword and the name followed by an equal sign. When destructuring, it also starts with the variable declaration keyword, but the equal sign and name will be placed after the closing curly brace or closing square bracket.
What is the syntax for defining an arrow function?
You need parenthesis that covers your parameter, then the arrow and curly braces. You have to put parentheses if you have multiple parameters or no parameter, but you can skip the parenthesis if you have one parameter.
When an arrow function’s body is left without curly braces, what changes in its functionality?
In this case, I don’t need a return statement.
How is the value of this determined within an arrow function?
The left side of the this (left side of the dot) will be the value of this. If there is nothing on the left then this value will be a global window.
What is a CLI?
Command Line Interface. It accepts text input to execute operating system functions.
What is a GUI?
Graphical User Interface. It’s an interface that uses windows, icons, and menus to enable easy interaction.
Give at least one use case for each of the commands listed in this exercise.
man: When I want to see the command keyword
cat: When I want to concatenate files to standard output.
ls: When I want to see the list information about the files in the current directory.
pwd: When I want to check or print the full name of the current working directory.
echo: When I want to type in to the standard output. It
touch: When I want to update the access and modification times of each file to the current time.
mkdir: When I create the new directory.
mv: When I rename the directory name. Rename SOURCE to DEST or move SOURCE to DIRECTORY.
rm: When I want to remove the file.
cp: When I want to copy the SOURCE to DEST or multiple SOURCEs to DIRECTORY.
What are the three virtues of a great programmer?
Laziness, impatience, and hubris.
What is Node.js?
It’s a program that allows JavaScript to be run outside of a web browser. Node.js is powered by V8, which is the same JavaScript engine in the Google Chrome browser.
What can Node.js be used for?
It can be used when you want to execute what you write in JavaScript.
What is a REPL?
It stands for Read Eval Print Loop. It’s a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user. Ex) Console dev tools in browser.
When was Node.js created?
It was invented in 2009 by Ryan Dahl.
What back-end languages have you heard of?
Python, PHP, Ruby, Java, JavaScript, Go, Rust, C, C++, C#, Kotlin, Elixir.