JS109 Flashcards
What is the broader term for
Variables declared with let and var
Constants declared with const
Properties of the global object
Function names
Function parameters
Class names
Identifier
Are object keys ever identifiers?
No, not all of them.
But all of them are on the global object
What happens when you do a variable declaration?
Asks the JavaScript engine to reserve space for a variable with a particular name.
What is the name for =
assignment operator
assignment operator
=
let function = function() {
??what is this space??
}
the function body
Difference between function call and invocation?
Same
But “invocation” and “invoking” are easier to distinguish noun and verb.
You invoke a function to call it or write a function invocation that will be called when the program runs
Are parameters just variables
Yes basically
A function that always return boolean are called…
a predicate
What is a predicate?
predicates are functions that always return boolean
All JavaScript function calls evaluate to a value t or f
T
If it’s not defined it returns undefined
When a method mutates the object it was called on it’s called
mutates the caller
What is it called when you pass a function as the argument into a function?
like this:
add(subtract(80, 10), times(subtract(20, 6), add(30, 5)));
function composition
What is this operator called %
remainder operator
modulo operation
You cannot invoke a function expression before it is declared t or f
T
What does it mean to be first class functions? (2 things)
They are treated like values and can be assigned to variables. They can also be parsed into other functions as arguments
Describe how the callstack works:
1 function first() {
2 console.log(“first function”);
3 }
4
5 function second() {
6 first();
7 console.log(“second function”);
8 }
9
10 second();
https://launchschool.com/books/javascript/read/functions#callstack
Push to the stack
Pop from the stack
Stack frame
The call stack helps JavaScript keep track of what function is executing as well as where execution should resume when the function returns.
main, initial stack frame called the main function
main
Program execution reaches a function invocation, and updates the main stack frame with the current program location. So it knows where to come back to when it’s done executing this function.
Then a new stack frame is pushed onto the stack for this new function:
second
main: line 10
Main is inaccessible and dormant until second completes.
The program reaches another function invocation. The second frame is updated with the line so JS knows where to resume execution later.
first
second: line 6
main: line 10
Etc. When it comes back, it starts executing again immediately after the invocation.
second: line 6
main: line 10
second: line 7
main: line 10
main:line 10
then an empty stack when the program finishes.
What is one level of the stack called?
Stack frame
What is the conditional part of a loop called?
A clause