In this blog we can see what is Anonymous functions in TypeScript .
Anonymous Functions in TypeScript :
TypeScript anonymous functions are functions that aren’t attached to an identifier, hence they lack a function name.
For inline functions, anonymous functions are utilised. When a function is only used once and doesn’t require a name, these are used.
Syntax :
var varName = function( [arguments] ) {
// function body
}
Example :
var result = function(a:number, b:number) {
return a+b
}
var c = result(17,3)// c= 20
Example 2 :
Anonymous function with no arguments
var displayMessage = function () {
console.log(“Hello!”)
}
displayMessage()
For any Help or Queries Contact us on info@crmonce.com or +918096556344