Basic Javascript Guide

Overview


Declaring Variables


One of the first steps to writing a program, is to understand how to declare and manipulate variable. A variable is a name that is given to a piece of data. The following shows two simple examples.


let age = 12;
let name = "steven"
            
Variable Types

Varaibles can hold different types of data. In the examples above, the variable age is assigned a numeric value, while the name variable is given a piece of text. The kind of data that a variable holds is referred to as its type. The type of data determines what you can do with the data. For instance, you can subtract numeric types, whereas, its not clear what subtracting two pieces of text would be.

Javascript is a simplified language in that you only really need to know a limited number of types.

  • number
  • text
  • date
  • array
  • dictionary (or object)
  • function


For a more detailed information about javascript data types, please see: data types

Contents