Languages
[Edit]
EN

TypeScript - arrow functions

0 points
Created by:
Diana
720

In this article, we would like to show you how to create and use arrow functions in TypeScript.

Quick solution:

with arguments:

without parentheses:

 

1. Arrow function with no arguments

Edit

In this example, we create a simple arrow function with no arguments.

Output:

2. Arrow functions with arguments

Edit

In this example, we create a simple arrow function that displays its arguments in the console.

Output:

3. Arrow functions without parentheses

Edit

In this example, we create an arrow function with no parentheses. The function multiplies the given number by 2. Notice that in this kind of function you don't need the return statement.

Output:

4. Arrow function vs regular function

Edit

In this example, we present a comparison of the arrow function with a normal function.

Arrow function solution:

is equal to:

See also

Edit
  1. JavaScript - arrow functions 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join