Mega Code Archive

 
Categories / JavaScript Tutorial / Array
 

Add element to the begin of an array by using Array unshift

< html> <head> <title>Adding to the Beginning</title> <script language="javascript" type="text/javascript"> <!-- var x = new Array(1,2,3,4); var newLength = x.unshift(0); alert(x.length); alert(x); //--> </script> </head> <body> <h1>Adding to the Beginning</h1> </body> </html>