Formatting

Moment.js

Replacing Moment.js moment().format()

Vanilla JavaScript
const moment = (date = new Date()) => ({
  format: () => new Intl.DateTimeFormat('en-US', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit'
  }).format(new Date(date))
});

// Usage:
// moment().format(); // "10/01/2023"

Why Use This?

Moment.js was once the standard for dates, but it is deeply mutable and has an enormous bundle size. The native `Intl` object is built directly into modern browsers and handles internationalization natively without downloading huge locale dictionaries.