Sr side Flashcards
What is a code block? What are some examples of a code block?
the code inside brackets
use const, and if you HAVE TO, use let
true
What does block scope mean?
it means things only apply inside the code block
What is the scope of a variable declared with const or let?
block scope, they stay inside the code block
What is the difference between let and const?
const is immutable, let is not
const cannot be reassigned,
Why is it possible to .push() a new value into a const variable that points to an Array?
tho it can’t be reassigned, the value can be changed and added to a variable in arrays (and others?)
robert says this is a language problem
How should you decide on which type of declaration to use?
Always use const unless the compiler says you cannot. Robert says it is better to default to const
What is the syntax for writing a template literal?
backtics and ${ }
in the substitution you can put an expression (do math, function calls (JS functions always return a value, even if undefined))
What is “string interpolation”?
the ability to substitute part of the string for the values of variables or expressions
should you use string interpolation if you don’t substitute?
no, just use quotation marks as interpollation is not needed. Robert’s quote is that just because you can do something it doesn’t mean you should do something.
What is destructuring, conceptually?
an alternative, way to assign properties of an object to variables …
… which can be done efficiently in batches?
…
What is the syntax for Object destructuring?
let { property1: variable1, property2: variable2 } = object;
curly braces
What is the syntax for Array destructuring?
square braces
How can you tell the difference between destructuring and creating Object/Array literals?
which side the equal sign shows up on
What is the syntax for defining an arrow function?
On the left you need parentheses for no parameters or more than one parameter. If it’s just one parameter then you don’t need any parentheses. Then you need the arrow, and on the right side you need the expression or if it is an object or something you need curly braces
When an arrow function’s body is left without curly braces, what changes in its functionality?
it returns the expression
How is the value of this determined within an arrow function?
It doesn’t work. Arrow functions do not accept the this keyword
Per Robert, should you ever not use parens in arrow functions?
You should always use the, even if there is only one parameter, and even tho u technically can omit the parens
What is a CLI?
command line interface
What is a GUI?
it is like cli but it’s graphic
(vs code has a gui of the cli for github)
What are the three virtues of a great programmer?
- Laziness: The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful and document what you wrote so you don’t have to answer so many questions about it.
- Impatience: The anger you feel when the computer is being lazy. This makes you write programs that don’t just react to your needs, but actually anticipate them. Or at least pretend to.
- Hubris: The quality that makes you write (and maintain) programs that other people won’t want to say bad things about.
What are the 3 components of a fullstack Web architecture?
The frontend that the user interacts with (Web site or Mobile app)
The backend server that takes requests from the frontend and processes them
The database where data is stored and used across all instances of the frontend
What is Node.js?
Node.js is a program that allows JavaScript to be run outside of a web browser.
extra:
It is commonly used to build backends for Web applications, command-line programs, or any kind of automation that developers wish to perform. Node.js is powered by V8; the same JavaScript engine in the Google Chrome browser. It is free, open-source software and its source code is available on GitHub.