Use .has and .size on an ES6 Set

FCC link

Let's look at the .has and .size methods available on the ES6 Set object.

First, create an ES6 Set

var set = new Set([1, 2, 3]);

The .has method will check if the value is contained within the set.

var hasTwo = set.has(2);

The .size method will return an integer representing the size of the Set

var howBig = set.size;

Test

{{test}}

Console output