December 2017
Beginner
372 pages
10h 32m
English
Duck typing in computer science means that if an object has the same properties and methods as defined in any known type, then the object can be treated as that type and it does not need to be explicitly marked as that type. The interfaces in TypeScript are a form of duck typing, as we will see in the following example:

Here, we define an interface with two properties and one method. We also have an Article class, which has the same signature as that of the interface. Then, we have a function named news, which takes one parameter of the IArcticle type. As you can see in line number 20, we can pass the object of the Article class ...
Read now
Unlock full access