Visit complete TypeScript roadmap
TypeScript Topic

Functions

Functions

Functions are a core building block in TypeScript. Functions allow you to wrap a piece of code and reuse it multiple times. Functions in TypeScript can be either declared using function declaration syntax or function expression syntax.

Function Declaration Syntax:

function name(param1: type1, param2: type2, ...): returnType {
  return value;
}

Function Expression Syntax:

function add(a: number, b: number): number {
  return a + b;
}

let result = add(1, 2);
console.log(result); // 3

Learn more from the following links:

More Topics

Explore related content

View All Topics
Loved by 100K+ Developers

Start Your Learning
Journey Today

Join thousands of developers who are leveling up their skills with structured roadmaps and expert guidance

No credit card required
Always free
Track your progress