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( "不存在" );
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM