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.
2. Function Expressionfunction a(){console.log('shreyash')}a()
Assign a function in variable. function acts like a value this is the function expression
3. Named Function Expressionvar a = function (){console.log('shreyash')}a()
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()Orvar a = function (){console.log('shreyash')}a()
4. First Class Function
Difference between Parameters and Arguments? 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')}
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){ //parametersconsole.log(name)}a('shreyash') // argument
Post a Comment