Getting the value associated with the key(get method)
Now, we have the key-value pairs on the Map, and now we are going to concentrate on how can we get the value associated with the key from the Map. We got a method for this, which is the get method. With this method, we just have to specify for what key, do we need the value? Means value associated with which key, that key needs to be passed here, and then we are going to get the value of the corresponding key –
Let’s have a look at a simple example, through which, we can understand the get method here.
Now, what if we give such a key, which is not present on the Map? Well, you can try doing this. It is going to give undefined in such a case.