A glimpse of JavaScript and TypeScript

frontend

a learning recap

I spent one day to learn javascript and typescript. Since I already have experience with JS, React, and other languages (both OOP and FP), it didn't take me much time to grasp the core features. Many of them are similar across different programming languages.

JavaScript

object / class / prototype chain / async programming / api

TypeScript

Typescript is a superset of javascript with syntax for types. It add types for type safety and compile time type check to catch issues early.

types (implicit any type) / tsc (compiler) / structural type system / union type (narrow down types) / OOP programming(interface, class, generic types)

React / Redux

React is a front-end library that helps develop web pages. The core idea is to divide parts of pages into components offering reusability and composability, similar to function composition.

Redux is for state management, acting as a global state store for react. Every component can query the store from anywhere. Thus we don’t need to pass states and props from one component to another. It’s a unified place to manage states. Its four core concepts are:

  1. Action. An object representing an event that influences the state.
  2. Reducer. A function defining how the state changes in response to an action. I would say it’s the callback that will be called when an event happens.
  3. Dispatch. Dispatch the action to store or trigger the event in another saying.
  4. Store. A global state storage.

Learning Materials