可以用数组的indexof函数,方法arr.indexof(find,start);find:要找的内容,必须;start:查找开始下标,可选;返回:查找数据所在的下标,如果没找到,返回-1如果只要知道是否有8这个数字,直接调用arr.indexof(8),如果返回值不为-1,说明找到了vars=[1,2,3,5,6,9];varu=s.indexof(5);//返回5所在的下标3vard=s.indexof(8);//返回-1console.log(u);console.log(d);
js 数组查询:js数组套对象[朗读]
@mtrang
顶0
加入收藏
相关问答推荐