CodesJava

Easy learning with example program codes

typescript arrow function


A TypeScript function is a group of statements which is used for performing a specific task. It provides the facility of code re-usability.

Typescript lambda or arrow functions are used to represent anonymous functions.

Parts of Arrow / Lambda function:

  • Parameters
  • Arrow notation/lambda notation (=>)
  • Statements

Typescript Arrow / Lambda function syntax:

( [param1, parma2,…param n] )=>statement;

Typescript Arrow / Lambda function example:

var calculateSquare = (num:number)=> {    
   num = num * num; 
   console.log(num); 
} 
calculateSquare(10);

Try it:

JS Bin on jsbin.com
 

Please follow and like us:


Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki