Java Script


JavaScript Tutorial


Admission Enquiry Form


Function with no argument and no return in JavaScript

When function does not take any value as an argument and does not return any value.


Syntax Function with no arguments and no return value

function functionName()
{  
 //statements to be executed  
}  

Example of Function with no arguments and no return :

<html>
<head>
<title>Function with no argument and no return</title>
</head>
<body>
<script>
function wish() //defintion of function
{
alert("Welcome you in Compuhelp");
}
wish(); //calling of wish function
</script>
</body>
</html>


Output:


Example of Function with no arguments and no return on button click:

<html>
<head>
<title>Function with no argument and no return</title>
<script>
function sum()
{
var num1=100;
var num2=200;
var res;
res=num1+num2;
alert("Sum is "+res);
}
</script>
</head>
<body>
<h2>Click on Button to see the output</h2>
<input type="button" name="btn" value="sum" onClick="sum()">
</body>
</html>


Output:

In the above example,when we click on sum button it will give the output as 'Sum is 300'.