Synchronous

Synchronous means the code is executed line by line, and each line of code waits for previous line to finish.

But if some code will take some time to finish, it might block the thread, so we need a way to solve this problem.

Asynchronous


The actual contents comes from The Complete JavaScript Course 2021.

If you have interests, you can check The Complete JavaScript Course by Jonas Schmedtmann.

What is DOM?

It’s structured representation of HTML documents.

Allows JavaScript to access HTML elements and styles to manipulate them.

So we can say DOM is a connection point between HTML documents and JavaScript code.

When does DOM create?

The DOM is automatically created by the browser as soon as the HTML page loads.

And it’s stored in a tree structure like this:


The actual contents comes from The Complete JavaScript Course 2021.

If you have interests, you can check The Complete JavaScript Course by Jonas Schmedtmann.

After Compiling, Execution in Detail

  1. Global Execution Context is created for the top-level code.
  2. Top-Level code be executed.
  3. After Top-Level code is finished, functions start to execute.

What is top-level Code?

It’s code that is not inside any function, in the beginning only the code that is outside of functions will be executed.

What is Execution Context?


The actual contents comes from The Complete JavaScript Course 2021.

If you have interests, you can check The Complete JavaScript Course by Jonas Schmedtmann.

JavaScript Engine

JavaScript Engine is a computer program that executes JavaScript code.

Every browser has its own JavaScript engine, the most well-known engine is Google V8.

Call Stack and Heap


The actual contents comes from UI.DEV React Router v5.

If you have interests, you can check React Router v5 by Tyler McGinnis.

What’s the mental model of React Router?

Route is gonna either render the children component if matched or it’s gonna render null.

And Route is just another component, we can render routes anywhere inside of our application.

Nested Links


The actual contents comes from Epic React’s Advanced React Patterns Workshop.

If you have interests, you can check Epic React by Kent C. Dodds.

Code Splitting (Dynamic Import)

The module must have a React component as the default export, and we have to use the <React.Suspense /> component to render a fallback value while the user waits for the module to be loaded.

Load when Event Happened


The actual contents comes from Epic React’s Advanced React Patterns Workshop.

If you have interests, you can check Epic React by Kent C. Dodds.

Context Module Functions


The actual contents comes from Epic React’s React Hooks Workshop.

If you have interests, you can check Epic React by Kent C. Dodds.

useState

useState is a function that accepts a single argument which is the initial state.

useState returns a pair of values.

The first of the pair is the state value and the second is a function we can call to update the state.

What is State?

State can be defined as: data that changes over time.

Lazy State Initialization


The actual content comes from Kent C. Dodds.’s Epic React Course.

useState

useState is a function that accepts a single argument which is the initial state.

useState returns a pair of values.

The first of the pair is the state value and the second is a function we can call to update the state.

What is State?

State can be defined as: data that changes over time.

Lazy State Initialization

useState allows us to pass a function instead of the actual value, and then it will only call that function to get the state value when the component is rendered the first time.

useEffect

useEffect is a built-in…

Shunze

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store