Array Destructing in JavaScript

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

Program 1

<html>
    <head>
        <title>Array Desctructing in JS</title>
        <script>
              function employee()
              {
                   return(["Vijay Verma",44,67000,"CSE"])
              }
              let[ename,eage,esal,edept]=employee()
              console.log(ename)
              console.log(eage)
              console.log(esal)
              console.log(edept)

            //   function employee([ename,edept="HR",esalary])
            //   {
            //     console.log(ename)
            //     console.log(edept)
            //     console.log(esalary)
            //   }

            //   employee(["Rajesh Mishra","CSE",65000])

        //   let emp=["Nilesh Mishra","CSE",26,["Indore",60000,"Male"]]

        //    let [ename,edept,eage,[ecity,esalary,egender]]=emp

        //     console.log(ename)
        //     console.log(edept)
        //     console.log(eage)
        //     console.log(ecity)
        //     console.log(esalary)
        //     console.log(egender)

            //  let emp1=["Vikas Sharma","CSE",25,"Indore",70000]
                          
            //  let [ename, ...values]=emp1 
             
            //  console.log(ename)
            //  console.log(values)
            //  console.log(edept)
            //  console.log(eage)

             
              
        </script>
    </head>
 
    <body>
      <center>
            
     </center>
    </body>
</html>

 

Your opinion matters
Please write your valuable feedback about DataFlair on Google

courses

Leave a Reply

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