November 2019
Beginner
804 pages
20h 1m
English
Internally, the _todoList field is defined as ReadonlyArray<TodoItem>. Don't worry too much about the angle brackets for now; instead, focus on the type. This is a read-only array of the TodoItem objects. Using ReadonlyArray is very beneficial because it ensures that the array content cannot be changed directly. All mutating methods are gone; thus, for example, you cannot re-assign elements in the array or use methods such as push to add items to it.
This might be counterintuitive for programmers with a strong OO background, but it will actually increase the safety of our code. For example, in the constructor, we accept an optional argument called todoList. If the given argument is defined and is a ...
Read now
Unlock full access