December 2017
Beginner
372 pages
10h 32m
English
Function overloads allow us to define multiple functions with the same name but different implementations. This concept is very prevalent in traditional object-oriented languages but not so much in JavaScript. TypeScript does allow function overloads but the syntax and implementation are a bit clunky.
In TypeScript, function overload is accomplished by providing multiple function definitions, but only one implementation. The implemented function, then, has to make sure that it handles all the different function definitions and perform an action based on the definitions. In the following example, we will define two function overloads and one implementation, which will also handle the overloaded functions:
function getCustomer(name ...
Read now
Unlock full access