JS Modify & Delete Array


Modify Array Element

<!DOCTYPE html>
<html>
<head>
  <title>JavaScript</title>
  <script>
    var a = ["Harry",18,"Male","BCA"];
    document.write(a + "<br>");
    a[0] = "Sunny";
    document.write(a + "<br>");
    a[1] = 20;
    document.write(a + "<br>");
  </script>
</head>
<body>
</body>
</html>


Delete Array Element

<!DOCTYPE html>
<html>
<head>
  <title>JavaScript</title>
  <script>
    var a = ["Harry",18,"Male","BCA"];
    document.write(a + "<br>");
    a[0] = "Sunny";
    document.write(a + "<br>");
    delete a[1];
    document.write(a + "<br>");
  </script>
</head>
<body>

</body>
</html>