Javascript Data Type How to - Delete the first element from array








Question

We would like to know how to delete the first element from array.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
<!--from ww  w .ja v  a 2 s . co  m-->
var a = [1, 2, 3,4,5,6]
delete a[0]
document.writeln (a[0] === undefined)
document.writeln('<br/>');
document.writeln(a.join('|'));
document.writeln('<br/>');
document.writeln(a.length);
</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: