Home
Chat
This website collects cookies to deliver better user experience
OK
You Complete Guide To Set Object In Javascript
You Complete Guide To Set Object In Javascript
Hi everybody, I'm
Aya Bouchiha
, on this amazing day, we will talk about
all Set Methods and Properities
like
has()
,
add()
,
size
.
Definition of a Set
Set
: is a collection of items and a built-in object, which stores only unique values.
Set Constructor
Iteration over a Set using For of loop
Size Property
size
: is a set property that returns the length of the unique items in a specified set.
Set Methods
Set.prototype.add()
add(valueToAdd)
: is a set method that lets you add a new element to the specified Set.
Set.prototype.delete()
delete(valueToDelete)
: is a set method that lets you remove an element in a specified Set.
Set.prototype.clear()
clear()
: means deleting all set elements.
Set.prototype.has()
has(valueToCheck)
: cheks if the given value exists in a set.
Set.prototype.entries()
entries()
: returns an array(
iterator
) [val, val] for each item in the specified Set.
Set.prototype.values()
values()
: like
keys()
, It returns a new iterator object which contains the values for each element in the specified Set.
Set.prototype.forEach()
forEach(callback)
: this Set method invokes a callback for each element in the specified Set.
Summary
size
:returns the length of the unique items in a specified set.
add(valueToAdd)
: lets you to add a new element to the specified Set.
delete(valueToDelete)
:lets you remove an element in a specified Set.
clear()
: delete all Set elements.
has(valueToCheck)
: cheks if the given value exists in a set.
entries()
: returns an array(
iterator
) [val, val] for each item in the specified Set.
values()
: returns a new iterator object which contains the values for each element in the specified Set.
forEach(callback)
: invokes a callback for each element in the specified Set.
References
www.w3schools.com
www.developer.mozilla.org
Have a great day!
email:
[email protected]
telegram:
Aya Bouchiha
32
0
Categories:
Javascript
Typescript
Tags:
Javascript
Typescript
Webdev
Tutorial
Related Posts
loading...
loading...
loading...
loading...
loading...
loading...
loading...
loading...
Post Comment
Show Comments
A bug that made me a better developer.
How to build powerful tables in React using the React Table package
Implementing tables using reactjs
Next.js Authentication with Netlify Identity
Websites To Learn Programming For Free
C# For Beginners - Lesson 6: Strings
NodeJS vs Python
Best Website Speed and Performance Testing Tools Free