← Back to Tutorials Chapter 15

References

This chapter is a quick-reference guide to JavaScript’s core types, operators, built-in objects, and methods. Use it as a cheat sheet when writing code or preparing for interviews.

Core Data Types

TypeExampletypeof
Number42, 3.14"number"
String"hello", 'world'"string"
Booleantrue, false"boolean"
Undefinedundefined"undefined"
Nullnull"object"
BigInt9007199254740991n"bigint"
SymbolSymbol("id")"symbol"
Object{a:1}, [1,2]"object"

Operators Reference

CategoryOperators
Arithmetic+ - * / % ** ++ --
Assignment= += -= *= /= %= **=
Comparison== === != !== > < >= <=
Logical&& || ! ??
Bitwise& | ^ ~ << >> >>>
Ternarycondition ? expr1 : expr2
Spread / Rest...arr

Class Syntax Reference

class Animal {
  constructor(name) { this.name = name; }
  speak() { console.log(`${this.name} makes a sound.`); }
  static classify() { return 'Mammal'; }
}

class Dog extends Animal {
  constructor(name, breed) {
    super(name);
    this.breed = breed;
  }
  speak() { console.log(`${this.name} barks.`); }
}

Array Methods

// Iteration
arr.forEach(fn); arr.map(fn); arr.filter(fn); arr.reduce(fn, init); arr.some(fn); arr.every(fn);

// Mutation
arr.push(v); arr.pop(); arr.shift(); arr.unshift(v); arr.splice(i, n); arr.sort(fn); arr.reverse();

// Access / search
arr.concat(arr2); arr.slice(i, j); arr.indexOf(v); arr.find(fn); arr.findIndex(fn); arr.flat(depth);

// Static
Array.from(iterable); Array.of(v1, v2, ...); Array.isArray(v);

String Methods

"hello".toUpperCase(); "HELLO".toLowerCase();
"hello".trim(); "hello".charAt(0); "hello".indexOf("e");
"hello".slice(1, 4); "hello".split(""); "hello".includes("ell");
"hello".startsWith("he"); "hello".endsWith("lo");
"hello".replace("l", "x"); "hello".repeat(3);
"a,b,c".split(","); "hello".padStart(10, "*");

Number & Math Methods

Number.isNaN(v); Number.isInteger(v); Number.parseFloat("3.14"); Number.parseInt("42", 10);
Number(v).toFixed(2);
Math.round(3.7); Math.floor(3.7); Math.ceil(3.2);
Math.min(1, 5, 3); Math.max(1, 5, 3);
Math.random(); // 0 to < 1
Math.abs(-5); Math.pow(2, 3); Math.sqrt(16); Math.PI;

Date Methods

const d = new Date();
d.getFullYear(); d.getMonth(); d.getDate(); d.getDay();
d.getHours(); d.getMinutes(); d.getSeconds();
d.toISOString(); d.toLocaleDateString(); d.toLocaleTimeString();
// Setting
d.setFullYear(2025); d.setMonth(11); d.setDate(25);
// Timestamp
Date.now(); d.getTime();
JavaScript reference sheet

Browser Compatibility

All examples in this tutorial target modern browsers (Chrome, Firefox, Safari, Edge). For older browser support, use caniuse.com to check feature availability and consider transpilers like Babel and polyfills like core-js.

Keep learning: The MDN Web Docs (developer.mozilla.org) is the most authoritative JavaScript reference. Bookmark it and consult it regularly.

Exercise: Build Your Own Cheat Sheet

Create an interactive HTML page that displays all Array methods. For each method, show its syntax, a short description, and a clickable “Run Example” button that logs the result to the console. Use the data-* attributes to store the method name and parameters.