Foundations Flashcards

1
Q

Scope

A
  1. Global scope
  2. Local Scope/Function Scope
  3. Block scope
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Closures

A
  1. How to create closures? a combination of the lexical environment
  2. When is it created? creation phase
  3. Why do we need closures? data privacy, event handlers, and callback functions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Hoisting

A
  1. Moving declaration to the top(incorrect)
  2. Allow you to use a variable before declaring it
  3. function expressions are not hoisted
  4. Three Types: var(assign undefined), let/const(no initialized), function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Event Loop

A
  1. A Design pattern
  2. Monitor call stack and the task queue
  3. Push event to call stack when it’s empty
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Task Queue

A
  1. A new JavaScript program or subprogram is executed (such as from a console, or by running the code in a element) directly.
  2. An event fires, adding the event’s callback function to the task queue.
  3. A timeout or interval created with setTimeout() or setInterval() is reached, causing the corresponding callback to be added to the task queue.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Microtasks Queue

A
  1. JavaScript promises
  2. Mutation Observer API
  3. Can use queueMicrotask() by other third parties libs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Macrotasks Queue

A

Does not exist

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

Lexical Environment

A

A lexical environment is basically the scope or environment the engine is currently
reading code in. A new lexical environment is created when curly brackets {} are used,
even nested brackets {{…}} create a new lexical environment. The execution context tells
the engine which lexical environment it is currently working in and the lexical scope
determines the available variables.

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

Execution Context

A
  1. A simple environment that the code run-in
  2. Code is always in an execution context
  3. Two/Three Types, Global/Function and eval
  4. Two Stages (creation phase and execution phase)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Types

A
  1. Undefined
  2. Null
  3. Boolean
  4. Number
  5. BigInt
  6. String
  7. Symbol
  8. Function Object
  9. Object
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Scope Chain

A

Each execution context that has a link outside of it lexical environment called scope chain.

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

Dynamic Scope

A

this keyword

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

Primitive values

A
1. Type
string 
number 
bigint
boolean
null
undefined
symbol  
2. passed by value 
3. copied and passed somewhere else in the memory
4.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Non Primitive

A
  1. passed by reference (pointer)
  2. To make is primitive we can
    Object.assign
    {…}
  3. Only Shallow Copy, not Deep Copy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Currying

A

Currying is a transformation of functions that translates a function from callable as f(a, b, c) into callable as f(a)(b)(c)

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

Programming Paradigms

A
  1. OOP

2. FP