samsung s4 extremely hot Hi I have a samsung galaxy s4 that is less than a month old

The s4 when idle is around 28°Celsius and around normal usage it's around 32° 

The maximum the phone has ever got is 36° by using the street view on Google maps for 5 minutes

Normally when I keep the phone on while charging it gets quite hot so I keep it off it gets hot near the camera/earpiece not the battery

But today by accident I kept it on and after 10 minutes it got so hot that as soon as I held it for more than 2-3 seconds it felt like my hand would burn

The temp app read 39.2°c the hottest it's ever got

Now what I'm worried about is that could the phone getting so hot that it feels like it would burn your hand have done any damage to the phone already

After it cooled down I tested everything and it worked ok

Still worried things could be damaged inside
Unless you know for sure it became hotter than what it is designed for, I doubt you phone is damaged. One thing you didn't mention is where this temperature reading comes from ? If it reads the CPU temperature, 40°c is not that hot at all, a typical CPU can usually raise close to 90°c and I'm pretty sure the same is true for a phone CPU.

From my experience, the issue I have encountered on some occasions is that it looks like an application is stuck while using all the CPU resources without the user being aware. When it happens, I'm not using the phone at all and it is just using the battery and getting warm until I notice the heat. Then I usually need to reboot for this issue to be resolved. It doesn't look like my phone was permanently affected by these issues.