- function is an Object in javascript
- Javascript function has properties as well as methods.
- Normal function Declaration
- function functionName(argumentparemeters){ }
- Anonymous Function
- var pp (variable which will save the return value from function)=function(){
- alert(“Hi this is anonymous function”);
- }
- Constructor
- function Memeber(a,b){
- this.name=a;
- this.skill=b;
- }
- var t=new Member(“Pavan”,”Servicenow”);
- var g=new Member(“Pankaj”,Java”);
- function myFunction(a, b) {
return a * b;
}var x = myFunction(4, 3); - Arrow Functions
- // ES5
var x = function(p, q) {
return p * q;
}// ES6
const x = (p, q) => p * q;
- // ES5
- Call Back function
- A JavaScript Callback Function is a function that is passed as a parameter to another JavaScript function, and the callback function is run inside of the function it was passed into.
- function p1(x){ return x; };
- function p2(p1(1))
- function p1(x){ return x;}
- function p2(b, callback){ callback(b);}
- p2(2,p1);
- p2(3,function(){alert(“Hi”);})
- A JavaScript Callback Function is a function that is passed as a parameter to another JavaScript function, and the callback function is run inside of the function it was passed into.