Modern JavaScript

From Rixort Wiki
Jump to navigation Jump to search

Defining variables

  • Do not use var - it is not scoped to blocks (effectively it is a global variable) and it can be redefined
  • Use const for values which must not change and which can be set on initialisation (remember that properties of the object *can* change, even though the object pointed to cannot)
  • Use let for values which may change