Monday, 11 January 2016

Java script 7

Function Declarations

 function functionName(parameters)

 {
  code to be executed

Example

function myFunction(a, b)
 {
    return a + b;
}

Function Expressions

A function expression can be stored in a variable:

Example

var x = function (a, b) {return a + b}; 
 
 

Functions Can Be Used as Values

 

Example

function myFunction(a, b)
 {
    return a + b;
}

var x = myFunction(4, 3);
 

Function Parameters and Arguments

  

functionName(parameter1, parameter2, parameter3)

 {
    code to be executed
}  

No comments:

Post a Comment