October 2017
Intermediate to advanced
280 pages
6h 50m
English
We're already familiar with how to define a new function in JavaScript. We can use function expression or function declaration:
// function expression
var isPrime = function (n) {
// body
};
// function declaration
function isPrime(n) {
// body
};
Alternatively, we can use the new arrow function syntax:
var isPrime = n => {
// body
};
The only thing TypeScript alters is the feature to define the types of the arguments of the function and the type of its return result (that is, the signature of the function). After the compiler of the language performs its type checking and transpilation, all the type annotations will be removed. If we use function expression and assign a function to a variable, we will be able to define ...
Read now
Unlock full access