js splice()
Posted guomengkai
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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"]
以上是关于js splice()的主要内容,如果未能解决你的问题,请参考以下文章