JavaScript

TypeScript Basics for JavaScript Developers

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. It adds optional static typing, interfaces, and other features that make large codebases much more maintainable.

Basic Types

let name: string = 'Alice';
let age: number = 30;
let isActive: boolean = true;
let tags: string[] = ['ts', 'js'];

Interfaces

interface Post {
  id: number;
  title: string;
  content: string;
  published?: boolean; // optional
}

Functions

function greet(name: string): string {
  return `Hello, ${name}!`;
}

const add = (a: number, b: number): number => a + b;

Generics

function first<T>(arr: T[]): T {
  return arr[0];
}

const num = first([1, 2, 3]);    // type: number
const str = first(['a', 'b']);   // type: string

Related Posts

Getting Started with Node.js

Node.js has revolutionized server-side JavaScript development. In this post, we'll cover everything you need to know to get started building scalable applications.

May 28, 2026
Understanding Async/Await in JavaScript

Async/await syntax makes working with asynchronous code much cleaner and easier to reason about. Here's a deep dive into how it works under the hood.

May 15, 2026
Building REST APIs with Express

Express makes building REST APIs in Node.js remarkably straightforward. This tutorial walks through creating a full CRUD API from scratch.

April 15, 2026