How to write a function in typescript?
In Typescript, a function in TypeScript can be written in two ways:
Named Function
This type of function is written and called using its own name.
Example:
function display() {
console.log("Hello Best Interview Question Team!");
}
display(); //Output: Hello Best Interview Question Team
Anonymous Function
In this function, the code is written and stored through expressions or variables. The variable/expression name is used to call the stored data types.
Example:
let greeting = function() {
console.log("Hello Best Interview Question Team");
};
greeting(); //Output: Hello Best Interview Question Team
BY Best Interview Question ON 25 Jul 2020