Senior Side Week 1 Flashcards
What is a code block? What are some examples of a code block?
A code block is when their are lines of code that is grouped together. Typically code blocks are grouped by curly braces. Some example of code blocks are if statements, for loops, while, and do while loops
What does block scope mean?
Block scope means that any variable or function is only visible within that block of code and not outside of it
What is the scope of a variable declared with const or let?
They have a block-level scope.
What is the difference between let and const?
Const variable cannot change while let variable can.
Why is it possible to .push() a new value into a const variable that points to an Array?
The const keyword only applies to the variable reference (i.e., the memory address that the variable points to), not the value itself.
How should you decide on which type of declaration to use?
If the variable needs to be mutable later on, use let. If the variable doesn’t change at all, then use const. If you don’t know if it is going to change just use const and change it back later.
What is the syntax for writing a template literal?
The syntax is backticks (`)
What is “string interpolation”?
The syntax used is ${expression}. It is when you can insert the value of the expression within the string. Makes it easier to read the code.
What is destructuring, conceptually?
It makes it the code more concise and easier to readable. It allows us to assign elements in array or objects to variables so that it is easier to grab
What is the syntax for Object destructuring?
let { firstName: fname, lastName: lname } = person;
//this is for renaming the variable
or
you can keep it like this
let { firstName, lastName } = person;
//this doesn’t rename it
What is the syntax for Array destructuring?
Instead of brackets that are used in objects, we use square brackets with a variable name for each element for each index.
let [x, y, z] = array;
How can you tell the difference between destructuring and creating Object/Array literals?
We can tell by which side the object and array is in the expression.
What is the syntax for defining an arrow function?
=>
When an arrow function’s body is left without curly braces, what changes in its functionality?
The arrow function will automatically return the expression. If the expression is more than one statement then you you need curly braces and a return syntax
How is the value of this determined within an arrow function?
The “this” is determined by the scope in which the arrow function is defined and not where it is called
What is a CLI?
CLI stands for command-line interfaces. Uses the command-line interface to receive commands from a user in the form of lines of text.
What is a GUI?
GUI stands for graphical user interface. It is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, instead of text-based UIs, typed command labels or text navigation. Typically used by consumers and not developers.
man
Definition: an interface to the system manuals
Description: man is the system’s manual pager. Each page argument given to man is normally the name of a program, utility or function. The manual page associated with each of these arguments is then found and displayed. A section, if provided, will direct man to look only in that section of the
manual. The default action is to search in all of the available sections following a pre-defined order (see DEFAULTS), and to show only the first page found, even if page exists in several sections.
Use Case: Used to find commands if you don’t know one
cat
Definition: concatenate files and print on the standard output
Description: Concatenate files to standard output
Use Case: to know what is in the file
ls
Definition: list directory contents
Description: List information about the FILEs
Use Case: To see what files are in the directory
pwd
Definition: print name of current/working directory
Description: Print the full filename of the current working directory
Use Case: to know the full path
echo
Definition: display a line of text
Description: the String(s) to standard output
Use Case: not really
touch
Definition: change file timestamps
Description: Update the access and modification times of each File to the current time.
A file argument that does not exist is created empty, unless -c or -h is supplied.
A file argument string of - is handled specially and causes touch to change the times of the file associated with standard output.
Use Case: makes a timestamp for a file and it can create a new file
mkdir
Definition: make directories
Description: Create the directory(ies) if they do not already exist.
Use Case: When you want to create a folder
mv
Definition: move (rename) files
Description: Rename source to dest, or move source(s) to directory
Use Case: to rename files
rm
Definition: remove files or directories
Description: removes each specified file. by default, it does not remove directories.
Use Case: To delete files