How to delete an entry using JavaScript ?

Bharathi Cherukuri
Posted by Bharathi Cherukuri under JavaScript category on | Points: 40 | Views : 1220
The "delete" operator removes an array element, but it does not change the size of the array.
See the below example for clear explanation.

<script type="text/javascript">
var days = ["Sunday","Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday"];
document.write("Number of days:"+days.length);
delete days[4];
document.write("<br />Number of days:"+days.length);
This produces
Number of days:7
Number of days:7

Comments or Responses

Login to post response