Variables

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
  1. 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.
  2. let - Variable has block scope and it is not hoisted
  3. 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

  1. Number
  2. Bigint
  3. String
  4. Boolean
  5. null
  6. Undefined
  7. Symbol

Here is the list of reference data types

  1. Objects
  2. Functions
  3. Arrays

Youtube | Facebook | Twitter | Website Home | Online Grocery Shopping Brisbane