js splice()

//arrayObject.splice(index,howmany,item1,.....,itemX) 语法
//测试代码
let array;
array = ['George','John','Thomas','James','Adrew','Martin'];
cc.log('array = ' + jsonencode(array));
array.splice(1,0,'gmk');
cc.log('array = ' + jsonencode(array));

array = ['George','John','Thomas','James','Adrew','Martin'];
cc.log('array = ' + jsonencode(array));
array.splice(1,1);
cc.log('array = ' + jsonencode(array));

//测试代码log
//array = ["George","John","Thomas","James","Adrew","Martin"]
//array = ["George","gmk","John","Thomas","James","Adrew","Martin"]
//array = ["George","John","Thomas","James","Adrew","Martin"]
//array = ["George","Thomas","James","Adrew","Martin"]
posted @ 2019-08-15 14:16  流星曳尾  阅读(290)  评论(0编辑  收藏  举报