Do you want to be a good Web Developer?

Enter Your Email To Get Our Exclusive Tutorials
And Offer Right In Your Email

Javascript Functions

Javascript Functions

Functions are the block of code that we want to use again and again simply by calling with their name.

You can make your own functions and use them whenever and wherever you want just simple by making a function and calling that function.

Syntax of Creating a Function

function functionName() 
    Your code here;

//For calling your function

Example of Function

function demo()
  alert( "Hello Javascript" );

This will display Hello Javascript.

Syntax of Function with parameters

function functionName(parameters) 
    your code here

/*For calling your function*/

You can send as many parameters in function as you want.

Example of Function with parameters

function demo(val)
  alert( "Here is your value is "+val);


This will display Here is your value 10.

Example of Function Return Value

function demo(val)
  var add=val+10;
  return add;

var val2 = demo(10);
alert( "Here is your value "+val2 );

This will display Here is your value 20.


Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email