Variables and data types in javascript


You do not need to declare variables before using them. But it is not good practise. You can force variable declaration using "use strict" statement at the beginning of the script. Variables can be declared using 3 ways var - Variable has function scope and it is hoisted. Variables created without the keyword var have global scope even if they are created inside a function. let - Variable has block scope and it is not hoisted const - similar to Const. Const variables can be assigned only once

Variables Types

You can find the type of any variable using typeof operator. Here is the list of primitive data types
  • Number
  • Bigint
  • String
  • Boolean
  • null
  • Undefined
  • Symbol
Here is the list of reference data types
  • Objects
  • Functions
  • Arrays
Complex problems, Simple Solutions