Grokking TypeScript
Vote

0% completed

​

Arrow Functions

The same pricing rule takes three lines as a regular function and one line as an arrow function, and for a small rule the two behave the same.

function doublePrice(price: number): number { return price * 2; } const doublePriceArrow = (price: number): number => price * 2; console.log(doublePrice(5)); // Output: 10 console.log(doublePriceArrow(5)); // Output: 10

Arrow functions came to JavaScript with ES6, and TypeScript supports them fully

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content