Skip to main content

JavaScript

JavaScript is the programming language of the web. Originally designed for browser interactivity, it has evolved into a versatile language running everywhere from servers (Node.js) to mobile apps to IoT devices.

Key Characteristics

  • Dynamic typing: Variables can hold any type
  • First-class functions: Functions are values
  • Prototypal inheritance: Object-based, not class-based (though classes exist)
  • Event-driven: Asynchronous by nature
  • Single-threaded: One call stack (with async capabilities)

Modern JavaScript (ES6+)

// Arrow functions
const greet = (name) => `Hello, ${name}!`;

// Destructuring
const { name, age } = user;
const [first, ...rest] = items;

// Spread operator
const merged = { ...defaults, ...options };

// Async/await
const data = await fetchData();

// Optional chaining & nullish coalescing
const city = user?.address?.city ?? 'Unknown';

Runtime Environments

EnvironmentUse Case
BrowsersWeb applications, interactivity
Node.jsServers, CLI tools, scripts
DenoSecure Node alternative
BunFast all-in-one toolkit
ElectronDesktop applications
React NativeMobile applications

What We Like

  • Ubiquity: Runs everywhere, known by everyone
  • Ecosystem: npm is the largest package registry
  • Flexibility: Multiple paradigms (functional, OOP, procedural)
  • Rapid iteration: Quick feedback loop in browsers
  • Full-stack: Same language frontend and backend

What We Don't Like

  • Can't think of any 😉

JavaScript vs TypeScript

For most projects, we recommend sticking with JavaScript because it's easier to understand for most developers and usually faster to work with. We'd use TypeScript if the codebase or application requires it - such as when working in a large team or for added safety in complex projects.

AspectJavaScriptTypeScript
TypesDynamic, runtimeStatic, compile-time
ErrorsRuntimeCaught in IDE
ToolingGoodExcellent
Learning curveLowerHigher

Best Practices

  1. Lint your code: ESLint with Airbnb or similar config
  2. Prefer const/let: Never use var
  3. Consider TypeScript: For any non-trivial project