GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||
GeezerVison is showing www.geeksforgeeks.org — JavaScript Set Reference - GeeksforGeeks JavaScript Set ReferenceLast Updated : 23 Jul, 2025 JavaScript Set is a collection of items that are unique, meaning no element can be repeated. Elements of the set can be iterated in the insertion order. A Set can store any type of value, whether primitive or objects. Syntaxnew Set()Example: This example will show the use of Set() constructor.
Output: Set(4) { 'California', 'India', 10, { a: 5 } }The complete list of JavaScript Set has listed below: JavaScript Set ConstructorA constructor is called when an object is created using the new keyword.
JavaScript Set PropertiesA JavaScript property is a member of an object that associates a key with a value. Instance PropertyAn instance property is a property that has a new copy for every new instance of the class.
JavaScript Set MethodsMethods are actions that can be performed on objects. Instance MethodIf the method is called on an instance of a Set then it is called an instance method.
Comparison with JavaScript Arrays
Examples and Use Cases1. Creating a SetCreating a Set and adding elements to the set.
Output Set(3) { 'apple', 'banana', 'cherry' }
2. Adding and Deleting ElementsAdding new elements and Deleting the elements.
Output Set(3) { 1, 5, 'Hello' }
Set(2) { 1, 'Hello' }
3. Checking for Element ExistenceChecking for already existing elements.
Output true false
| ||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |