ES6 - Set 方法 has()



如果找到元素,則返回 true,否則返回 false。

語法

下面是 has() 的語法,其中,value 是 Set 中要搜尋的值。

set_name.has(value)

示例

<script>
   let names = new Set(['A','B','C','D']);
   console.log(names.has('B'))
</script>

以上程式碼的輸出如下 −

true
廣告
© . All rights reserved.