Cheatsheets

One-page references for the syntax you'll forget in a week. Press Ctrl + P on any cheatsheet page to save it as PDF.

JavaScript Essentials

javascript
// VARIABLES
let count = 5;             // mutable
const PI = 3.14;           // immutable

// CONDITIONALS
if (age >= 18) {
  // ...
} else if (age >= 13) {
  // ...
} else {
  // ...
}

// LOOPS
for (let i = 0; i < 10; i++) { /* ... */ }
for (const item of items) { /* ... */ }
while (condition) { /* ... */ }

// FUNCTIONS
function greet(name) { return `Hi, ${name}!`; }
const greet = (name) => `Hi, ${name}!`;

// ARRAYS
const xs = [1, 2, 3];
xs.push(4);                // [1,2,3,4]
xs.length;                 // 4
xs.map(n => n * 2);        // [2,4,6,8]
xs.filter(n => n > 2);     // [3,4]

// OBJECTS
const user = { name: "Aisha", age: 30 };
user.name;
user["age"] = 31;
Object.keys(user);

// I/O (Node)
console.log("hello");

Python Essentials

python
# VARIABLES
count = 5
PI = 3.14   # convention only

# CONDITIONALS
if age >= 18:
    pass
elif age >= 13:
    pass
else:
    pass

# LOOPS
for i in range(10):
    pass
for item in items:
    pass
while condition:
    pass

# FUNCTIONS
def greet(name):
    return f"Hi, {name}!"

# LISTS
xs = [1, 2, 3]
xs.append(4)
len(xs)
[n*2 for n in xs]
[n for n in xs if n > 2]

# DICTS
user = {"name": "Aisha", "age": 30}
user["name"]
user["age"] = 31

# I/O
print("hello")
name = input("Your name? ")

Java Essentials

java
// VARIABLES
int count = 5;
final double PI = 3.14;

// CONDITIONALS
if (age >= 18) { /* ... */ }
else if (age >= 13) { /* ... */ }
else { /* ... */ }

// LOOPS
for (int i = 0; i < 10; i++) { /* ... */ }
for (Item item : items) { /* ... */ }
while (condition) { /* ... */ }

// METHODS
public static String greet(String name) {
    return "Hi, " + name + "!";
}

// ARRAYS / LISTS
int[] xs = {1, 2, 3};
List list = new ArrayList<>();
list.add(4);

// HASHMAP (objects)
Map user = new HashMap<>();
user.put("name", "Aisha");
user.get("name");

// I/O
System.out.println("hello");
Scanner sc = new Scanner(System.in);
String name = sc.nextLine();
💡
Tip

To save as PDF: press Ctrl + P (or Cmd + P), then choose "Save as PDF" as the printer. The site's print stylesheet hides everything except the cheatsheet.