INTRODUCTION TO JAVASCRIPT

     JavaScript is a lightweight and server-side language. JavaScript can execute on a device that has a special program called the JavaScript engine. JavaScript is used to design dynamic web pages with HTML and CSS.


JavaScript Frameworks

  •   Angular
  •   React
  •   Node.js
  •   Vue
  •   Ember
  •   Polymer
  •   BackBone

Function In JavaScript

 

Function Declaration


when declaring a function we use the function keyword.


function add(number1 ,number2)

{

return number1 + number2;

}


In the above example add is the function name and number1, number2 are the arguments that we pass to the function.


Function Invocation


add(number1, number2);


when we declare an anonymous function, let see how to call an anonymous function call

var func = function (){

    alter("This is an anonymous function");

}

func();


🔷Named Function

function add(number1 ,number2)

{

return number1 + number2;

}


🔷Anonymous Function

var addNumbers = function ()
{
return number1 + number2;
}

🔷Arrow Function

() => {
console.log("Hello World");
}

(number1, number2) => {
return number1 + number2;
}


Let see another example

var printHello = function (){
    console.log("Hello World");
}

function printer(func){
    func();
}

printer(printHello);

In the above code, an anonymous function assign to printHello variable. Then create another function named printer by passing the function pointer as an argument. Then call printer function by passing printHello function pointer.

Comments

Popular posts from this blog

Introduction To MongoDB

Introduction To React JS