Object Destructing in JavaScript

Free Web development courses with real-time projects Start Now!!

Program 1

<html>
    <head>
        <title>Object Desctructing in JS</title>
        <script>
                    let student= 
                    {
                          stid: 101,
                          stname:  "Viraj Gupta",
                          stage: 24,
                          stcourse: "BCA"
                    }
                    let{stid:id, stname:name, stage:age, stcourse:cr}=student

                    console.log(id)
                    console.log(name)
                    console.log(age)
                    console.log(cr)

                    let student1= 
                    {
                          stid1: 102,
                          stname1:  "Nilam Mishra",
                          stage1: 25,
                          stcourse1: "MTech"
                    }
                    let{stid1:id1, stname1:name1, stage1:age1, stcourse1:cr1}=student1


                    console.log(id1)
                    console.log(name1)
                    console.log(age1)
                    console.log(cr1)
        </script>
    </head>
 
    <body>
      <center>
            
     </center>
    </body>
</html>

 

If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

courses

Leave a Reply

Your email address will not be published. Required fields are marked *