CodesJava

Easy learning with example program codes

typescript anonymous 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.

A function created without function name is known as anonymous function.

Typescript anonymous function syntax:

var result = function( [arguments] ) { ... }

Typescript anonymous function example:

var sayHello = function() { 
   return "Hello World!";  
} 
console.log(sayHello());

Typescript anonymous function with parameters example:

var sayHello = function(name:string) { 
   return "Hello "+name;  
} 
console.log(sayHello("Jai"));

Try it:

JS Bin on jsbin.com
 

Please follow and like us:


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