SOURCE

var answersAll=[];
answersAll[0]={
    "id":"1111",
    "questionType":3,
    "answerContent":["题1"]
   }
answersAll[1]=
    {
    "id":"2222",
    "questionType":3,
    "answerContent":["题2"]
   }
answersAll[2]=
    {
    "id":"3333",
    "questionType":3,
    "answerContent":["题3"]
   }
answersAll[3]=
    {
    "id":"4444",
    "questionType":3,
    "answerContent":["题4"]
   }


answersAll[4]=
    {
    "id":"kkkk",
    "questionType":3,
    "answerContent":["题5"]
   }



var previous=0;
var current=-1;

if(current==-1){
    answersAll=(answersAll.slice(0,previous+1));
}else{
    // console.log(JSON.stringify(answersAll));
    previous=0;
    // current=4;

    answersAll=(answersAll.slice(0,previous+1)).concat(answersAll.slice(current));

    // answersAll=answersAll.slice(current);

}
    console.log(JSON.stringify(answersAll));


// // 查到下一题的 questionId 为5,  获得其题id为kkkk
// if(answersAll[3].id==="kkkk"){   //说明,
//     answersAll=(answersAll.slice(0,previous+1));
// }else{  }


    // if(current!=(previous+1)){
    //     //删除中间内容
    //     // for(){

    //     // }

    // }else{
    //     //
    // }
    // // console.log(JSON.stringify(answersAll));









// function findElem(array, attr, val) {
//     for (var i = 0; i < array.length; i++) {
//         if (array[i][attr] == val) {
//             return i; //返回当前索引值
//         }
//     }
//     return -1;
// };

// let hasIdFlag = findElem(answersAll, 'id', '13807146f85c4fdcb00206be6f596a7c');


// console.log(hasIdFlag)


// ————————————————
// 版权声明:本文为CSDN博主「mossbaoo」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
// 原文链接:https://blog.csdn.net/mossbaoo/article/details/113241678
//     for (var i = 0; i < answersAll.length; i++) {
//         if (answersAll[i][attr] == "13807146f85c4fdcb00206be6f596a7c") {
//             flag=i
//         }
//     }
console 命令行工具 X clear

                    
>
console