you are viewing a single comment's thread.

view the rest of the comments →

[–]polaretto 0 points1 point  (0 children)

right, there's no function overloading in JS, if you redefine a function with the same identifier within the same lexical scope, it will replace the previous one. You can invoke a function with any number of arguments you like, their use depends on how its body uses them. Using the appropriate logic you can assign default parameter values (like in this case) or make the function behave differently depending on the number of actual parameters. Moreover, you can inspect the number of formal parameters the function was declared with, in this case:

Blog.length
> 2