JavaScript Example (Program)
Learn Details

Arrow function

Arrow function का use traditional function के बदले किया जाता है।

Syntax :

1. Single statement

functionName () =>//your statement here

2. Multiple statement

functionName () =>{
//your statement here
}


Q. What is the diffrent between traditional function & Arrow


sr.no Traditional (ES5) Function let
1. इसमें function keyword का use होता है इसमें function keyword का use नहीं होता है
2. इसमें Arrow Sign (=>) का use नहीं होता है इसमें Arrow Sign (=>) का use होता है
3 Syntax 1
function functionName(){
//your statement here }
Multiple statement
functionName () =>{
//your statement here }
4 Syntax 2
functionName = function (){
//your statement here }
Single statement
functionName () =>//your statement here


Q. Diffrent between "traditional function" & "Arrow function" ?

traditional function



<script>    
    let myfunc = function (){
    let a = "Teach";
    let b = "Coders";
    return (document.write(a+" "+b));
  }
  myfunc();      
    }
</script>
 

Arrow function

<script> //Muliple Statement function with return keyword let myfunc2 = ()=>{ let a = "Teach"; let b = "Coders"; return (document.write(`<br> Hello, ${a} ${b}. This is a Arrow Function`)); } myfunc2() //Single Statement function with return keyword let myfunc3 = ()=> document.write("<br>Hello, I am Teach Coders."); myfunc3(); //Muliple Statement function with parameter and return keyword let add = (x, y)=>{ var c = x+y return(document.write(`<br>Total Value is :${x} + ${y}= ${c}`)) } add(90, 20) </script>