<sectionid="description">既然您已经完成了ES5,那么您将在ES6中执行类似的操作。这将相当容易。 ES6包含一个内置的数据结构<code>Set</code>现在包含了您手动编写的许多操作。我们来看看:创建一个新的空集: <code>var set = new Set();</code>您可以使用值创建一个集合: <code>var set = new Set(1);</code>您可以使用数组创建一个集合: <code>var set = new Set([1, 2, 3]);</code>创建集合后,可以使用<code>add</code>方法添加所需的值: <blockquote> var set = new Set([1,2,3]); <br> set.add([4,5,6]); </blockquote>提醒一下,集合是一种不能包含重复值的数据结构: <blockquote> var set = new Set([1,2,3,1,2,3]); <br> // set仅包含[1,2,3] </blockquote></section>