x
 
1
<!DOCTYPE html>
2
<title>My Example</title>
3
4
5
<p id="msg"></p>
6
7
<hr>
8
<p>The first parameter of <code>slice()</code> is a zero-based index to specify where the extraction begins. It extracts up to (but not including) the second parameter.</p>
9
<script>
10
  var cities =  ["Tokyo", "Auckland", "Sydney", "Brisbane", "Cairns", "London"];
11
      citiesAU = cities.slice(2, 5);
12
  document.getElementById("msg").innerHTML = cities + "<br>" + citiesAU;
13
</script>