HOW TO DELETE AN ARRAY ENTRY USING JAVASCRIPT?

Amit Singh

Total Post:565

Points:2825
Posted by  Amit Singh
 1496  View(s)
Ratings:
Rate this:
  1. Amit Singh

    Post:565

    Points:2825
    How to delete an array entry using JavaScript?

    The "delete" operator removes an array element in JavaScript , but oddly does not change the size of the array.
    For Example:
    <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);
    </script>

    Output:
    Number of days:7
    Number of days:7

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!