Hello, in this JavaScript video, I am going to cover sets. So the set collection is an object that lets you safely store unique values of a talk whether its primitive values, or you know object references. Well, so you could have duplicates in there, but the way you access them encourages you not to have duplicate. Let me show you photo var equals new cert. I'm gonna name this too. And you can actually add value using the dot add method as well.
Bob's going to keep it simple, and just have square brackets here. So say 1234. That's enough to demonstrate what I'm trying to show you the console dot log. First of all on console, log out the entire set, you see 12345 For the console dot log s t, and we can, you know, let's say do.we cannot check if it has a particular value. So by for example, and I'll do a null, check if he has nine, which it doesn't have to remember what number it is true and false. So it does have five right here, but has nine doesn't have nine.
For change this to five, let's see how our results change. As you can see, they don't, and the set will only just store the value. So you know, that is a very, very important part of it. If you want to get a value, let's do console dot log. Log, I think you don't need to get a value because once you've confirmed that a value there, you can simply just, you know, get it. You can simply Just once you'll start looking at the value there, you know there therefore you can do whatever you want with it.
Let me show you how to sort of go over your entire set with the for loop before and next item of St. And if we do console dot log and printer Alton it prints out all the values but again, it doesn't print out that duplicate flight. So we will if What if I change this to a five as well, the set will just have one five and free because the reason he put us in that first instance of the fiber era. So that's set slipcase is basically like arrays but you have unique values. So if you need that functionality sets is the way to go. Any questions, feel free to follow me method and I look forward to seeing you in the next programming video.