SENIOR SIDE Flashcards
ES6-CONST-LET
What is a code block? What are some examples of a code block?
a code block is anything within curly braces.
i.e. function code block, if statements, etc.
ES6-CONST-LET
What does block scope mean?
it means that variable declared within the code block are only for that block, i.e. local vs global variables
ES6-CONST-LET
What is the scope of a variable declared with const or let?
block scope
ES6-CONST-LET
What is the difference between let and const?
VAR Yes Yes Function Scope Yes
LET Yes No Block Scope No
CONST No No Block Scope No
ES6-CONST-LET
Why is it possible to .push() a new value into a const variable that points to an Array?
When you’re adding to an array or object you’re not re-assigning or re-declaring the constant, it’s already declared and assigned, you’re just adding to the “list” that the constant points to.
ex: we are not changing the typeof in the variable
ES6-CONST-LET
How should you decide on which type of declaration to use?
whether or not you ever want that variable to be redeclared or reassigned???
ES6-TEMPLATE-LITERALS
What is the syntax for writing a template literal?
` some text and ${some variable or property}`
ES6-TEMPLATE-LITERALS
What is “string interpolation”?
string interpolation is the process of evaluating a string literal containing one or more placeholders ${someVariable}, yielding a result in which the placeholders are replaced with their corresponding values.
ES6-DESTRUCTURING
What is destructuring, conceptually?
it is breaking down an object or array and assigning key/value pairs to a variable/value pair
ES6-DESTRUCTURING
What is the syntax for Object destructuring?
name = {
firstName: ‘Andy’,
lastName: ‘Chen’
}
const { firstName, lastName } = name
- this creates a variable named firstName with value of name.firstName and variable named lastName with a value of name.lastName
const { myName: firstName } = name
- this creates a variable named myName with value of name.firstName
ES6-DESTRUCTURING
What is the syntax for Array destructuring?
const someArray = [0 , 1, 2, 3, 4]
const [number1, number2, number3] = someArray
or to get the last ones after number3 then
const [ , , , number4] = someArray
ES6-DESTRUCTURING
How can you tell the difference between destructuring and creating Object/Array literals?
braces on the right side of the equal sign are creating
braces on left-hand side and that’s destructuring
ES6-ARROW-FUNCTIONS
What is the syntax for defining an arrow function?
const functionName = parameter => expression
or const functionName = (param1, param2) => param1 + param2
or const functionName = (param1, param2) => ( {param1:param2} )
ES6-ARROW-FUNCTIONS
When an arrow function’s body is left without curly braces, what changes in its functionality?
it has an implicit return
ES6-ARROW-FUNCTIONS
How is the value of ‘this’ determined within an arrow function?
arrow functions have a lexical scope (using global variables) so the value of ‘this’ is determined by the surrounding scope.
i.e. either window if it’s a global scope or local variable if arrow function is wrapped in a regular function
tim : arrow function = ‘this’ is defined at definition time
regular function = ‘this’ is defined at call time
COMMAND-LINE-BASICS
What is a CLI?
command line interface
COMMAND-LINE-BASICS
What is a GUI?
Graphical user interface
COMMAND-LINE-BASICS
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 = ultimate guide cat = combine files ls = check file directories pwd = print current working directory echo = print to terminal, like a console.log touch = create a new file mkdir = make directories / files mv = move and renames file rm = remove a file cp = copy a file
COMMAND-LINE-BASICS
What are the three virtues of a great programmer?
laziness, impatience, and hubris???
NODE-INTRO
What is Node.js?
Node.js is a javascript runtime. A program that allows JavaScript to be run outside of a web browser.
NODE-INTRO
What can Node.js be used for?
non-blocking, event driven servers
NODE-INTRO
What is a REPL?
read-eval-print loop, interactive top level or language shell
NODE-INTRO
When was Node.js created?
2009
NODE-INTRO
What back end languages have you heard of?
Python, MySQL, Node.js