In the preceding chapters, we also learned about immutability and the benefits of using immutable data objects. We learned that we can use the readonly keyword to declare immutable objects:
class Street {
public readonly num: number;
public readonly name: string;
public constructor(num: number, name: string) {
this.num = num;
this.name = name;
}
}
class Address {
public readonly city: string;
public readonly street: Street;
public constructor(city: string, street: Street) {
this.city = city;
this.street = street;
}
}
We also learned that working with immutable objects can sometimes be very verbose and tedious and that lenses can help us to overcome these difficulties. We are now going to learn about a library that can help us to declare immutable objects. The library is known as Immutable.js, and it also...