Common TypeScript features
There are some general features in TypeScript that don't apply specifically to classes, functions, or parameters, but instead make coding more efficient and fun. The idea is that the fewer lines of code you have to write, the better it is. It's not only about fewer lines but also about making things more straightforward. There are a ton of such features in ES6 that TypeScript has also implemented. In the following sections, we'll name a few that you are likely going to use in an Angular project.
Spread parameter
A spread parameter uses the same ellipsis syntax as the rest parameters but in a different way. It's not used as a parameter inside of a function
, but rather inside its body. Let's illustrate this with an example:
const newItem = 3; const oldArray = [1, 2]; const newArray = [...oldArray, newItem];
What we do here is add an item to an existing array without...