JS Array Slice & Splice


Array slice()

<!DOCTYPE html>
<html>
<head>
  <title>JavaScript</title>
  <script>
    var a = ["Sanjay", "Aman", "Rehman","Rahul", "Karan"];
    document.write(a + "<br><br>");
    var b = a.slice(1 , 4);
    document.write(b);
  </script>
</head>
<body>

</body>
</html>


Array splice()

<!DOCTYPE html>
<html>
<head>
  <title>JavaScript</title>
  <script>
    var a = ["Sanjay", "Aman", "Rehman", "Rahul"];
    document.write(a + "<br><br>");
    a.splice(2,0,"Neha","Karan");
    document.write(a);
  </script>
</head>
<body>

</body>
</html>