Vocabulary / Terms Flashcards

(40 cards)

1
Q

Execution Context

A

The execution context is the environment in which a JavaScript function is being executed. Each execution context has its own variable scope.

Whenever a function is invoked, a new execution context is pushed onto the call stack, and a new variable environment is created along with it. The function’s code runs in the new execution context and has access to the variable environment in the execution context directly below that new execution context (the one in which the function was invoked).

Upon exit of the function, the execution context is popped off of the call stack. Code in one execution context is stopped until the code in the execution context above it finishes running.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Scope

A

What data is available at any given time… or:

Variable environments (or local memories) are commonly referred to as “scope.” While each execution context is stacked on top of the execution context preceding it, each scope is created inside of the previous scope. Code being executed inside a scope not only has access to the variables in that scope, but also the variables in all the scopes that encase it. Therefore, code that runs in a given execution context has access to all the variables created in the execution contexts below it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a closure?

A

A closure is a variable environment that has outlived its execution context and remains attached to a function that also has outlived the same execution context.

If multiple functions are created in the same execution context and all of them outlive that execution context, those functions each have their own closure, and each of these closures will access the same variables in memory. Therefore, mutation of those variables by one of those functions will affect the other functions in the manner that they will be accessing the same (mutated) variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Names for closure data

A
  • Persistent Lexical Scope Referenced Data
  • C.O.V.E. - Closed Over Variable Environment
  • Closure
  • Backpack
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Method

A

A function attached to an object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Parameter

A

A variable that will have a value passed into a function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Argument

A

Value of a parameter passed into a function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Declare

A

Creating (and naming) a thing in memory (like a variable or function) . This is different from defining, as you can declare a variable without giving it a value (which would be defining it)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Define or Assignment

A

Giving a value to a variable or function. Can be used to mean Declare + Define if you are creating a variable or function and giving it a value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Initialize

A

When you declare a variable it is automatically initialized, which means memory is allocated for the variable by the JavaScript engine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
Describe this:
const test = addTwo(5);
A

Declaring a variable test, and assigning it to the evaluated result of the addTwo function, with the argument 5 passed in as its parameter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Implicit Parameter

A

this.whatever (this)

When a function is invoked, with the explicitly defined parameters that represents the argument, an implicit parameter this is also passed. The this parameter refers to the object that invoked the function. This is why this parameter is also known as function context.

function myFunc() { 
     return this;
}
myFunc();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

“Left of the dot rule”

A

poop.function() { this.val = 3 }
“this” equals whatever is left of the dot
In this example: this === poop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Constructor Functions

A

Functions made with the “new” keyword.

A constructor is a special function that creates and initializes an object instance of a class. In JavaScript, a constructor gets called when an object is created using the new keyword. The purpose of a constructor is to create a new object and set values for any existing object properties.

The following example defines a constructor function called Person:

function Person(firstName, lastName) {
    this.firstName = firstName;
    this.lastName = lastName;
}
let person = new Person('John','Doe');
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Basically, the new operator does the following:

Create a new empty object and assign it to the this variable.
Assign the arguments ‘John’ and ‘Doe’ to the firstName and lastName properties of the object.
Return the this value.

It’s functionally equivalent to the following:

function Person(firstName, lastName) {
    this = {};
// add properties to this

this. firstName = firstName;
this. lastName = lastName;

return this; }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Function Label

A

The assigned name or label of a function stored in memory. This points to the function definition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Function Definition

A

The code / meat of a function stored in memory. The function label points to this.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Thread

A

line by line of code in current execution context.

18
Q

Some uses of closure

A

storing data outside the global environment
memorize calculations
once-afy a function

19
Q

Dunder Proto __proto__

A

This is the name of the “bond” that links an object to it’s prototype.

Every object in JS has this property.

It points back to the prototype object of the constructor function that created that object.

The __proto__ property of Object.prototype is an accessor property (a getter function and a setter function) that exposes the internal [[Prototype]] (either an object or null) of the object through which it is accessed.

20
Q

Lexical Scope

A

What data was originally available at the birth of a function.

21
Q

Callback

A

A function passed as an argument to another function.

22
Q

Anonymous funciton

A

A function with no label in memory

23
Q

Base Case

A

Case where recursion is broken

24
Q

Side Effect

A

Side effects are reactions from actions performed in a function.

EX:
• Writing to console
• Drawing or writing to screen
• Modifying an external or global property

25
Pure Function
A Pure Function is a function (a block of code) that always returns the same result if the same arguments are passed. - Has no side effects, meaning it only modifies the code put into it. - Does not mutate the input
26
Return
return make the entire function evaluate to whatever is being returned.
27
single threaded
runs one line at a time
28
synchronous
each line executed in order
29
DOM
document object model: representation of the web page, and everything on it. JS calls this "document"
30
xhr
xml http request: - what lets you talk to the internet (what JS communicates with to talk to the internet) used with "fetch" in JS
31
Task Queue or Callback Queue
Queue in a browser where completed tasks that are ready for JS to run wait. ( when they have completed whatever is required of them from their non-JS functionally. I.E. Timer is complete, or data has been fetched via xhr.
32
Event Loop
Task Queue / Callback Queue checking if the Call Stack is empty and ready for the task / callback to begin in JS.
33
Promise Objeft
An object returned from some facade functions (like Fetch) that contain placeholder data for the action being performed, as well as a way to trigger a callback when data populates **default data:** value = undefined - - - hidden values --- onFulfilled = [] // anything listed here will be auto run onRejected = [] // anything listed here will be run if fail status // pending, then resolved or rejected - - - - - - - - - - - - - - - use .then() to add callbacks to onFulfilled (with the 2nd parameter of then() adding to onRejected
34
Microtask Queue
Queue at which promise object functions get put. This queue is executed before the Task Queue
35
DRY
DRY acronym stands for "Don't Repeat Yourself"
36
fundamental purpose of Object Oriented Programming
DATA next to FUNCTIONALITY
37
Object Literal
defining an object with curly brackets and the information contained within. I.E. Literally defining an object.
38
Creating object with NEW keyword
39
Creating object with Class
40
What is … called?
Spread sintax