Getting Started
Introduction
JavaScript is a lightweight, interpreted programming language.
- JSON cheatsheet (cheatsheets.zip)
- Regex in JavaScript (cheatsheets.zip)
Console
// => Hello world!
console.log("Hello world!");
// => Hello CheatSheets.zip
console.warn("hello %s", "CheatSheets.zip");
// Prints error message to stderr
console.error(new Error("Oops!"));
Numbers
Variables
let x = null;
let name = "Tammy";
const found = false;
// => Tammy, false, null
console.log(name, found, x);
var a;
console.log(a); // => undefined
Strings
let single = "Wheres my bandit hat?";
let double = "Wheres my bandit hat?";
// => 21
console.log(single.length);
Arithmetic Operators
5 + 5 = 10 // Addition
10 - 5 = 5 // Subtraction
5 * 10 = 50 // Multiplication
10 / 5 = 2 // Division
10 % 5 = 0 // Modulo
Comments
Assignment Operators
let number = 100;
// Both statements will add 10
number = number + 10;
number += 10;
console.log(number);
// => 120
String Interpolation
let age = 7;
// String concatenation
"Tommy is " + age + " years old.";
// String interpolation
`Tommy is ${age} years old.`;