~1 min read 0 comments

var, let, const and readonly`

There are two types of scopes in javascript, that is:

  • Local scope(Function scope)
  • Global scope

Variable declared as let has a local scope while var has a global scope. Variable declared as const is a constant. Property use readonly while variable use const.

interface vs class

  1. class is a concept in javascript, while interface only exists in typescript. The typescript compiler use interface solely for type checking.
  2. interfaces which has same name will merge

Reference

  1. https://stackoverflow.com/questions/43055682/relationship-between-a-typescript-class-and-an-interface-with-the-same-name
  2. https://www.typescriptlang.org/docs/handbook/interfaces.html