If some host sends a frame to another one that is not in the same LAN, a the frame arrives to a LAN switch, what does it do? I believe it would broadcast it, but I'm not sure about it. And what if both are on the same LAN? I think it would discard it, because it assumes it has arrived its destination if it's on the LAN already.
A switch really doesn't know that there are other LANs. Switches deal with the layer-2 (MAC) addresses. A switch will create a MAC address table table that relates a destination MAC address to the switch interface where the MAC address was last seen.
A frame destined for a different LAN will be addressed by the source host with the gateway MAC address as the destination MAC address, so the switch will forward the frame to the switch interface toward the gateway.
If a switch doesn't have a destination MAC address in its MAC address table, that is when it floods the frame to all the other switch interfaces.