deleting from a Javascript array and change its length - Javascript Array Operation

Javascript examples for Array Operation:Array Element

Description

deleting from a Javascript array and change its length

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from  w  w w .  ja  va2  s.c  o m
var arrayOne = [0,1,2],
    arrayTwo = [3,4,5];
delete arrayOne[1];
console.log("after delete: ", arrayOne.length);
arrayTwo.splice(1, 1);
console.log("array contents after splice(1,1): %o, with length: ", arrayTwo, arrayTwo.length);
    }

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

Related Tutorials