February 2019
Beginner
694 pages
18h 4m
English
As with any strongly typed language, there comes a time where you need to explicitly specify the type of an object. This concept will be expanded upon more thoroughly in the next chapter, but it is worthwhile making a quick note of explicit casting here. An object can be cast to the type of another by using the < > syntax.
Let's rewrite our previous sample, and use explicit casting, as follows:
var item1 = <any>{ id: 1, name: "item 1" };
item1 = { id: 2 };
Here, ...
Read now
Unlock full access