Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

has Method (Set) (JavaScript)

Returns true if the set contains the specified element.

setObj.has(value)

setObj

Required. A Set object.

value

Required. The element to test.

true if the set contains the specified element.

The following example shows how to add members to a Set and then check whether the set contains a specific member.

var s = new Set();
s.add("Thomas Jefferson");
s.add(1776);

document.write(s.has(1776));
document.write(s.has("1776"));

// Output:
// true
// false

Supported in the Internet Explorer 11 standards document mode. Also supported in Store apps (Windows 8.1 and Windows Phone 8.1). See Version Information. Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards. Not supported in Windows 8.

Show:
© 2015 Microsoft