Javascript Data Type How to - Remove the last item from an array








Question

We would like to know how to remove the last item from an array.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!--from w  ww. ja va  2  s  .co m-->
    var abc = ['a', 'b', 'c', 'd'];
    abc.pop()
    document.writeln(abc);
}
</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: