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