代码积累

2019-06-19  本文已影响0人  王牡丹爱写作

1。将某数据插入到数组的中的某位置,或者剪切数组某位置上的数据

    数组.splice(位置,个数,插入的数据)

2。拆分数组

function group(array,index,subGroupLength) {
      let newArray = [];      
     while(index < array.length) {

    for(var i=0;i<index.length;i++){
         newArray.push( array.slice(index[i], index[i] += subGroupLength[i]))
        }
      return newArray;
  }
}

3。定时器

d();

var time=9  
function d(){
        
t= setTimeout(d,1000);
        
time--;
        
console.log(time);
    
if(time==0){
        
clearTimeout(t);
        
}
    
}
function a(){
console.log("成功");
}
var time=9;
function d(){
    var t;
    time--;
    if(time==0){
        setTimeout(a,1000);
    }else{
    clearTimeout(t);
    t= setTimeout(d,1000)
    }
    console.log(time);

}
d();

3。得到某数在数组中的位置

    function getActualposition(Originalposition){//获取数组在数组中的下标的位置
        for(var a=0;a<vod_pic_detail.length;a++){
                if (vod_list[Originalposition].vod_pic==vod_pic_detail[a]) {
                    return a;
                }
        }
        return -1;
    }
上一篇 下一篇

猜你喜欢

热点阅读