javascript-today

Basics

Basics

If you are coming from any other language you will likely find this fairly familar.

Basic Types of variables

int – integer number 5, 123

float – floating number 3.14, 8.333333

string – string of character’s "sallys dog", "donut"

array – array of some type ["dog", "cat", "muskrat"], [3.14, 9.3333, 8]

objects – object of named values {key1: "dog", key2: "cat"}, {animal: "cat", age: 3}

functions

Basic variables declaration

const – a place to hold some type that will never change

example:

const pi = 3.14

let – declares a variable

example:

let dogName = "snowflake"

let dogAge = 5

Basic loop controls structures

for

for (let x; x > 5; x++){
  console.log("x: ", x);
}

for in

const person = {
  firstName: "John",
  lastName: "Doe",
  age: 30,
  occupation: "Developer"
};

for (let key in person) {
  console.log(key + ": " + person[key]);
}

foreach

while

Conditionals

if

Next Article: Variables