Home »
JavaScript Examples
JavaScript | Function call example with given number of arguments and less arguments
JavaScript function call example: Here, we are going to learn what happens/prints when a function is called with less number of arguments or no arguments?
Submitted by Pankaj Singh, on October 12, 2018
Function call example with given number of arguments and less arguments
Here, we are defining a JavaScript function named show() which has two arguments id and name and calling the function, with 1) both arguments, 2) one argument and 3) no argument.
Code:
<html lang="en">
<head>
<script>
function show(id,name){
document.write("Your name is <b>"+name+"</b> and your id is <b>"+id+"</b><br /><br />");
}
</script>
</head>
<body>
<script>
show(12,"pankaj");
show(12);
show();
</script>
</body>
</html>
Output
JavaScript Examples »