JavaScript Spread Operator

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

Program 1

<html>
    <head>
        <script>

           var a=[10,20,30,40,50]
           var b=[100,200,300,400,500]
           
        //    var c=a.concat(b)
        //    console.log(c)
          var c=[ ...a, ...b]
          console.log(c)
           
        //    var b=[...a]
        //    //console.log(b)
        //    a.push(600)
        //    console.log(b) 
          
          

         
            //   function display( ...args)  //rest operator
            //   {
            //           console.log(args)
            //   }

            //    var ar=[10,20,30,40,50,60,70,80]

            //    console.log(...ar)
            //    console.log([...ar])
              // display(...ar)  //Spread operator
            //    console.log("--------------------")
            //    display(10,20,30,40,50)
             
        </script>
    </head>
 
    <body>
      <center>
       <h1>Check error in code</h1>
     </center>
    </body>
</html>

 

Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google

courses

Leave a Reply

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