JavaScript tutorial 75 – type of functions in javascript




Types of JavaScript Functions:
Any function created using different ways of creating JavaScript functions, will be of one of the below mentioned type.
1. A function without parameters and without returning value
2. A function without parameters and with returning value
3. A function with parameters and without returning value
4. A function with parameters and with return value

Creating different types of functions using function declaration:
A function without parameters and without returning value:
Ex:
function wishHi()
{
document.write( “Hi” , ”<br/>” );
}
wishHi();

A function without parameters and with returning value:
Ex:
function wishHi()
{
return “Hi”;
}
document.write(wishHi());

A function with parameters and without returning value:
Ex:
function wish(what)
{
document.write( what , ”<br/>” );
}
wish(“good morning”);
wish(“good afternoon”);

Ex:
function add(num1,num2)
{
document.write( num1 + num2 , ”<br/>” );
}
add(2,2);

A function with parameters and with return value:

Ex:
function add(num1,num2)
{
return num1 + num2;
}
document.write(add(2,2));

function square(x)
{
return (x*x);
}
document.write(square(5));

========================================================

Follow the link for next video: https://youtu.be/gSC2WFw6NEQ

Follow the link for previous video: https://youtu.be/y9OsxaOLre4

========= For more benefits & Be up to date ===================
Subscribe to the channel:
https://www.youtube.com/chidrestechtu…

Like the Facebook fan page:
https://www.facebook.com/ManjunathChidre

Visit to Chidre’s Tech Tutorials website:
http://www.chidrestechtutorials.com

========================================================

Original source


2 responses to “JavaScript tutorial 75 – type of functions in javascript”

Leave a Reply