Saturday, 31 July 2021

JavaScript Playlist tutorial #14 | Full information on Arrow function and class @echocoding | soham


Arrow function and class Introduction of arrow function 00:20 class in JavaScript 5:45 ------------Subscribe channel please ----------- Arrow function is like a normal function but difference is we use here () in place of function . It is introduce in ES6. Arrow function is very easy to code and make our code reusable and clean We can also pass variable in arrow function Class is used in oops concept here I am going to give short introduction of class .
source code :-

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Arrow function</title>
</head>
<body>
   <script>
    //    function hello(){
    //     return document.write("this is coding");
    //    }
       hello = function(){
         return  document.write("this is coding");
       }
       hello();

    //    hi = () =>{
    //     document.write("<br>this is coding throw arrow function");
    //    }
    //    hi();
        
    hi = (x) => document.write("<br>this is coding throw arrow function"+x);
      
       hi(3333);

       class Car {
           constructor(name,year){
                this.name = name;
                this.year = year;
           }
       }

       var car1 = new Car("Ford",2000);      
       document.write(car1['name']);
       document.write(car1['year']);

       var car2 = new Car("Rrrr",1200);
       document.write(car2['name']);
       document.write(car2['year']); 



   </script> 
</body>
</html>




 

No comments:

By laptop