Wouldn't it have the same effect like if I was driving along and just took my foot off the gas for a few moments to slow down?
Yes. Exactly the same effect.
What would taking your foot off the gas do to the transmission?
It depends on whether you have a standard or an automatic, and what gear you're in.
With a standard, when you let off the gas, the transmission is still engaged and you immediately start to slow down. Your forward motion (kinetic energy) is being translated into heat in the transmission. If too much heat builds up (you use the transmission to slow yourself going down a long hill) then it will damage the transmission.
With an automatic, you typically coast when you let off the gas. The transmission is not engaged, and you slow slightly. As long as you're just in drive, versus first or second gear, this is fine. If you're in one of the lower gears, then the transmission is probably still engaged and you're in a similar situation as above. This is why putting an automatic in low gear and going down a hill is a bad idea.
with an electric car, wouldn't you want to hit the brakes to recharge the battery?
I don't know who told you that, DrewDad, but they were full of it. What you are describing is called "engine breaking" and it harms the transmission not at all. In fact, engine breaking is recommended during hard driving conditions, because your engine (NOT your transmission), unlike your breaks can handle extra heat. Other than higher end sports cars or those equipped with optional "big brakes"; overusing your brakes can be flat out dangerous. The more you use them; the hotter they get; the more they "fade" (which means less stopping power.) Too much abuse and they'll literally start on fire. Your engine on the other hand (NOT your transmission) has it's own cooling system (though some high end and towing vehicles cool the tranny too). At any rate; a transmission is no more bothered by heat when it's taking power from the motor to the wheels or vice versa. It is merely a go between; not the final destination.
Bottom line: I don’t want to argue with you, but neither do I want you spreading this disinformation for two reasons. 1. Its nonsense. 2. Its dangerous to overuse your brakes.
Btw, lower gears are always fine for engine braking. If you are in the mountains or towing something heavy, however, it’s a good idea to avoid overdrive altogether.