slice() 方法可从已有的数组中返回选定的元素。

好吧,我承认我竟然把它忘了!

这次我在回顾一下它

语法

arrayObject.slice(start,end)

数组.slice(起始,结束)

 

<script type="text/javascript">

var arr = new Array(6)
arr[0] = "George"
arr[1] = "John"
arr[2] = "Thomas"
arr[3] = "James"
arr[4] = "Adrew"
arr[5] = "Martin"

document.write(arr.slice(2,4) + "<br />")

</script>

 Thomas,James

选取数组索引第2到4

相关文章:

  • 2021-10-27
  • 2021-11-14
  • 2021-07-24
  • 2021-05-01
  • 2022-02-12
  • 2021-10-23
  • 2021-05-16
  • 2022-12-23
猜你喜欢
  • 2021-06-27
  • 2021-12-30
  • 2021-08-30
  • 2021-09-30
  • 2021-07-01
  • 2021-08-16
  • 2021-05-29
相关资源
相似解决方案