TypeScript lets you define function parameter types and return types explicitly.
Getting Started
What is TypeScript?
Basic Types
Types & Interfaces
Async TypeScript
Promises & Async/Await
TypeScript
Intermediate
FREE
Function Types
Lesson 1 of 17
Intermediate
Interactive
Syntax
TYPESCRIPT
function add(a: number, b: number): number { return a + b; } const multiply = (a: number, b: number): number => a * b;
Function Type Annotations
TYPESCRIPT
function add(a: number, b: number): number { return a + b; } const multiply = (a: number, b: number): number => a * b; function greet(name: string): string { return `Hello, ${name}!`; } console.log(add(5, 3)); console.log(multiply(4, 2)); console.log(greet("SukhNexus"));
Practice
1
Exercise
Practice this concept.
Answer
Write the code as shown above.
Quick Quiz
1
What did you learn?
This covers the basics.
Interview Questions
It is a fundamental TypeScript feature.