Skip to main content

Functions

Functions are one of the fundamental foundations of any JavaScript application. With the help of them, levels of abstraction, information hiding and modules are built. The TypeScript language slightly expands the capabilities of functions in comparison with JavaScript, making them even more convenient to work with.

Function description#

A typical description of a function in TypeScript with the definition of the type of the passed parameters and the type of the return value:

// определение функции
function add(a: number, b: number): number {
return a + b
}
// вызов функции
let result1 = add(1, 2)
console.log(result1)

Or we can define the function as a variable and then call this function through the variable:

let add = function (a: number, b: number): number {
return a + b
}
let result1 = add(1, 2)

Payment#

Now you are on a stripped-down version of the site, after subscribing to Patreon, you will get full access to the training course, as well as access to our server's private channels in Discord.

Download our mobile application or get tested in our JavaScript telegram bot, and also subscribe to our news.

Become a Patron!

Sumerian school

Links:#

  1. Foundations of TypeScript. Functions
  2. Article "TypeScript — Functions"
  3. Article "TypeScript — Script functions"

Contributors ✨#

Thanks goes to these wonderful people (emoji key):


Dmitriy K.

📖

Dmitriy Vasilev

💵

Resoner2005

🐛 🎨 🖋

Navernoss

🖋 🐛 🎨

Become a Patron!