Home  >  Article  >  Web Front-end  >  Detailed explanation of sample code for object types (Sets) in Javascript ES6

Detailed explanation of sample code for object types (Sets) in Javascript ES6

黄舟
黄舟Original
2017-07-17 11:30:591406browse

This article mainly introduces you to the relevant information about the introduction and use of Sets in Javascript. The article introduces it in detail through sample code, which has certain reference and learning value for everyone. It is needed Friends, please follow the editor to learn together.

Introduction

ECMAScript 6 (hereinafter referred to as ES6) is the next generation standard for the JavaScript language. Because the current version of ES6 was released in 2015, it is also called ECMAScript 2015.

Sets is a new object type in ES6 (ES2015), used to create a collection of unique values. The values ​​in the collection can be simple primitive types such as strings(strings) or integers (integers), or they can be more complex object types such as object literals or arrays.

Basic methods

The following are the basic set and its methods (add, size, has, forEach, delete, clear) simple example:

let animals = new Set();

animals.add('

The above is the detailed content of Detailed explanation of sample code for object types (Sets) in Javascript ES6. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn