js检测dict中是否包含某个key 数组中是否含有某元素

dict

ary.hasOwnProperty(key)

 

https://blog.csdn.net/donggx/article/details/53373497?utm_source=blogxgwz8

 

 

list

https://www.cnblogs.com/zaijin-yang/p/12196811.html

 

array.includes(searcElement[,fromIndex])

此方法判断数组中是否存在某个值,如果存在返回true,否则返回false

var arr=[1,2,3,4];
if(arr.includes(3))
    console.log("存在");
else
    console.log("不存在");
 
posted @ 2020-06-01 19:33  几许风雨  阅读(7605)  评论(0)    收藏  举报