What is function overloading in JavaScript?

JavascriptWeb DevelopmentFront End Technology

JavaScript does not support Function Overloading. The following shows function overloading −

function funcONE(x,y) {
   return x*y;
function funcONE(z) {
   return z;

The above will not show an error, but you won't get desired results. On calling,

// prints 5

// prints 5, not 30

JavaScript does not support function overloading natively. If we will add functions with the same name and different arguments, it considers the last defined function.

Published on 23-Feb-2018 12:15:42