Skip to content
Justice Tech School

Function Types

Type parameters and the return value. Function types describe callbacks.

Example
const add = (a: number, b: number): number => a + b;
type Fn = (x: number) => number;
const dbl: Fn = (x) => x * 2;
console.log(add(1, 2), dbl(4));

Result

3 8

Exercise

Return type.

function f():  { return 1; }

Quiz Test

Where is the return type written?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.