Show Menu
Cheatography

JavaScript Basics JavaScript Basics

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Primitive Types

Number: represents a number, whether it is an integer, a floati­ng-­point number, or a NaN (Not a Number).
String: represents a sequence of charac­ters, enclosed in quotes (single or double).
Boolean: represents a logical value of either true or false.
Null: represents a deliberate non-value or null reference.
Undefined: represents an uninit­ialized or undefined value.

Vari­ables Can Change Types

let numPuppies = 23;   // Number

numPuppies = false;   // Now a Boolean

numPuppies = 100;   // Back to Number!

Variables

Variables are like labels for values
We can store a value & give it a name in order to:
Refer back to it later
Use that value to do...stuff
Or change it later on

const

const works just like let, except you CANNOT change the value.

Bool­ean

Booleans are very simple.
You have two possible options:
true or false. That's it!
   

let syntax

Basic syntax:
let someName = value;


Recall values:
let hens = 4;

let roosters = 2;

hens + roosters //6

const syntax

const hens = 4;

hens = 20;  //ERROR!

Boolean syntax

let isLoggedIn = true;

let game0ver = false;

const isWaterWet = true;