I'm trying to set get id of all elements in an `HTMLCollectionOf`. I wrote the following code:

```
var list = document.getElementsByClassName("events");
console.log(list[0].id);
for (key in list) {
    console.log(key.id);
}

```

But I got the following output in console:

```
event1
undefined

```

which is not what I expected. Why is the second console output `undefined` but the first console output is `event1`?