JavaScript functions

Types of functions

  • Normal Function 
  • Function Expression
  • Named Function Expression
  • First Class function

1. Function Statement And function declaration.

     Function is set of instruction to perform a perticular task. without repeated the code. 

function a(){
    console.log('shreyash')
}
a()
2. Function Expression
     Assign a function in variable. function acts like a value this is the function expression  
var a = function (){
    console.log('shreyash')
}
a()
3. Named Function Expression
    A Named function expression means you can have the name of the function itself and put it to an expression.
var a = function fun1(){
    console.log('shreyash')
}
a()

Or

var a = function (){
    console.log('shreyash')
}
a()
4. First Class Function
    Pass function inside another function argument and it able to return function 
var a = function fun1(sirname){
    console.log('shreyash', sirname)
}
a(sirname())

function sirname(){
    console.log('kolhe')
}
Difference between Parameters and Arguments?
    The value pass inside an function is called an Argument a('shreyash'); and the function are gets this value are called as parameters function fun1(name){}.
function a(name){ //parameters
    console.log(name)
}
a('shreyash') // argument