在线文档教程

set.has

set.has

has()方法返回一个布尔值来指示对应的值value是否存在Set对象中

语法

mySet.has(value

参数

value需要. 需要是否存在于Set的值.

返回值

Boolean如果指定的值(value)存在于Set对象当中,返回true; 否则返回 false.

示例

使用has 方法

var mySet = new Set( mySet.add('foo' mySet.has('foo' // returns true mySet.has('bar' // returns false

规范

SpecificationStatusComment
ECMAScript 2015 (6th Edition, ECMA-262)The definition of 'Set.prototype.has' in that specification.StandardInitial definition.
ECMAScript Latest Draft (ECMA-262)The definition of 'Set.prototype.has' in that specification.Living Standard

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support38(Yes)13.0 (13.0)11257.1

FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic supportNo support38(Yes)13.0 (13.0)No supportNo support8