-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learning Angular, Fourth Edition
By :

Functions are the processing machines we use to analyze input, digest information, and apply the necessary transformations to data. Data can be provided either to transform the state of our application or to return an output that will be used to shape our application’s business logic or user interactivity.
Functions in TypeScript are not that different from regular JavaScript, except that, like everything else in TypeScript, they can be annotated with static types. Thus, they improve the compiler by providing the information it expects in their signature and the data type it aims to return, if any.
The following example showcases how a regular function is annotated in TypeScript:
function sayHello(name: string): string {
return 'Hello, ' + name;
}
There are two main differences from the usual function syntax in regular JavaScript. First, we annotate the parameters declared...