With that being said, creating functions with the same name is bad practice and should not be used. Instead, create a function like printText
that checks the number of arguments and prints different results depending on the parameters. This way, you don't have to put a value for each parameter and worry about accidentally printing undefined
. Either way, the possibility of running into this type of issue is pretty low, so don't worry too much about having to create methods that read the number of arguments
.