How does iPad already know Wifi login?

Last night I was visiting a friend and took my new iPad with me. At some point I got it out to look at something and just brought up Safari and did it. After about 10 minutes I realized I my iPad was connected to the wifi already. This iPad is brand new (setup as brand new as well) and I have never taken it to my friend's house before.

How did the iPad already have the login and was connected to my friend's network? Is this information somehow stored with my iCloud information?
Is it possible your friend has guest wifi setup not requiring a password. Could just be an open wifi.
It was connected to the secure wifi network, I'm sure of that. I setup my friend's network, there is no guest network active.
If you have enabled Keychain in Settings > iCloud on both your iPad and iPhone, and was previously connected to the wifi over at your friend with your iPhone, the wifi password is saved to Keychain.

This makes login in to wifi with your iPad unnecessary. That's one of the many good things of Keychain.
Ah I forgot about this thing. I know it's not active on my iPhone. But I think it is on my Macbook Pro and I have had that at my friends house so that must be it.

Thanks.

Original thread: https://forums.imore.com/threads/how-does-ipad-already-know-wifi-login.380501/