let barginFlag=[1,2,3,4]; let a=3; let b=9; //存在,flag1==0 let flag1= barginFlag.findIndex(item => item=== a) console.log(flag1) //不存在:flag2==-1 let flag2= barginFlag.findIndex(item => item=== b) console.log(flag2)