STACK = FE Glossary

1. Event-driven

JS = [1] single thread programming, [2] non-blocking by the event-driven mechanism.

Batch programming language

Multi-thread programming

Event driven

executes codes line by line

event loop, continuously check which event is triggered.

debug easier

race condition

used in OS

event-loop is single thread.

3 elements in event-loop

  1. event queue

  2. event loop

  3. event handler

Action

Scenario

1. Events, like click and type, will be accumulated in the queue.

2. The loop detects events and sends one to the handler. Then, the control is passed to the handler.

3. The handler processes the event, and returns the control back to the loop.

Repeat 2

Repeat 3

Process & thread

  • process has many threads.

  • Threads in a process share memory via sockets.

Stack & Heap

Stack

Heap

static memory

dynamic memory, determined at run time

variable

function, pointers

slower, but memory efficient.

2. Async pattern

2.1 callback hell

2.2 Promise

2.2.1 then / catch

2.2.2 async / await

2.2.3 generator

3. Middleware

extend functionality without modifying the code.

4. HOF / HOC

4.1. HOF

  • A function that accepts and/or returns another function is called a higher-order function. (reusability)

  • remember local scope.

  • ex: map, reduce, filter.

4.2. HOC

5. React & Redux

react: one-way data binding.

redux-action: plain object

redux-reducer: pure function without side effect

5.1. Why immutable

side effects = [1] less predictable [2] harder to test.

5.2. Functional programming

  • stateless

  • immutable

Last updated

Was this helpful?