October 2017
Intermediate to advanced
280 pages
6h 50m
English
Let's take a look at an example:
// ch4/modules/math.ts
export function square(x) {
return Math.pow(x, 2);
};
export function log(x) {
return Math.log(x);
};
export const PI = Math.PI; export const E = Math.E;
In the preceding snippet, we defined a simple ES2015 module in the math.ts file. We can think of it as a sample math Angular utility module. Inside it, we define and export the square and log functions and the constants E and PI. The const keyword is another keyword brought by ES2015 that is used to define constants. As you can see, what we do is nothing more than prefixing the definitions of the function with the export keyword. If we want to export the entire functionality in the end and skip the duplicate ...
Read now
Unlock full access