Set Objects
In JavaScript, a Set object stores unique values of any type. It ensures uniqueness, provides methods for manipulation, and doesn’t allow duplicate values within the set.
Syntax:
new Set( [it] );
Example: Here is the basic example of set object.
Javascript
const mySet = new Set(); mySet.add(1); mySet.add(2); mySet.add(3); // Duplicate value, ignored mySet.add(2); console.log(mySet.has(1)); console.log(mySet.has(4)); mySet. delete (2); console.log(mySet.size); // Outputs: 2 |
true false 2
JS 2015 or ECMAScript 6 (ES6)
JS 2015 (ES6) also known as ECMAScript 6 (ES6), ECMAScript 6 (ES6) is a significant update to JavaScript, introducing arrow functions, classes, template literals, let and const for variable declaration, enhanced object literals, destructuring, and more modern features for better code organization and readability.