Updated: 22 August 2025
ES6 arrow functions
- In regular functions the
this
keyword represented the object that called the function. - With arrow functions, the
this
keyword always represents the object that defined the arrow function.
Dates
const a = new Date(2000, 10, 17, 1, 2, 3, 456); // Month is zero indexed!
const b = new Date("2000-11-17T01:02:03.456Z"); // Standardised, works reliably.
console.log(a) // 2000-11-17T01:02:03.456Z
console.log(b) // 2000-11-17T01:02:03.456Z
// Number of days between 2 dates.
const c = new Date("2025-08-25T00:00:00.000Z");
const d = new Date("2025-10-20T00:00:00.000Z");
const ms_per_day = 86_400_000
console.log((d - c) / ms_per_day) // 56