What is a Function Overload?
Function overloads allow for functions to have different call signatures and return types based on what's passed in.
We have to use the
function keyword when using function overloads, which we will add above the original
In the overload, we'll specify what should be returned based on what is passed in.
0:00 For this exercise, we have a function called returnWhatIPassIn. All we need to do is return the type of the thing that we're passing in here. Currently, one is typed as unknown and matt is also typed as unknown because t here is typed as unknown. We've done this before, but with generics. This time, I want you to do with function overloads.
0:20 You are going to see that the resulting function is not as good, not as complete a solution as the generic one. All I need you to care about is these two cases. Don't have to care about the general case or handling every single case like twos, Pococks, or whatever. Just these two cases. You'll see that function overloads provides quite a nice API for it. Good luck.