原文链接:https://blog.csdn.net/weixin_45022563/article/details/119675272
1.数组是数字或者字符串类型的
var a = ["1","2"]; alert(a.indexOf("3"));//返回-1
2.数组是json对象
var a = [{name:"1"},{name:"2"}]; alert(a.findIndex(suibiandebianliangmingcheng=>{return suibiandebianliangmingcheng.name=="1"}));//返回0 alert(a.findIndex(suibiandebianliangmingcheng=>{return suibiandebianliangmingcheng.name=="3"}));//返回-1
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/tech/webdev/272609.html