Blogger Information
Blog 20
fans 0
comment 0
visits 14184
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
常用函数slice和splice实践-2019年1月16日22点08分
kszyd的博客
Original
644 people have browsed it
var arr=[1,2,3,4,5,6]; //slice 从数组中取出一部分元素
arr.slice(1,4);
arr.slice(1,-2);      //﹣代表从尾部开始取值

 splice()实现增删改查更新等功能;

var arr=[1,2,3,4,5,6];
arr.splice(4,0,'a');       //从第五个位置添加一个元素,0,边是不删除

arr.splice(3,2);   //从第4个位置删除两个

arr.splice(2,1,'b'); //更新,从第三个位置删除一个,再添加b到这个位置上

 

Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post