Leaving things plugged in?
Well most phones and laptops run on lithium battery's now, so it comes to the way they are made:
The battery will break if it runs all the way out of power so the device its in usually will shut down by its self before it dies all the way, if it don't the battery has a shut off safety in it too.
A battery will last so many cycles before it breaks down, a cycle is running it all the way down and then charging it all the way full, each time it happens you used a cycle and the cells in it get build up and its in the way of the next full charge so over time it last less and less.
The plug changes the power from ac to dc (house power to battery power) so the charger is really in the phone or laptop.
The charger shuts off when the battery is full, and when the power drops to a point (lets say 90-95%) of full battery the charger turns back on for a bit to top off the battery again so its not charging the whole time.
What hurts the battery most is heat which almost all of comes from the device not the charger or battery.
The worst thing to do is charge the battery when hot or really cold (should be luke-warm) charging a hot battery cost you cycles meaning it will last for less time next charge
You will hear it said its good to run it all the way down and full once a month or at some point, that's not true its bad for the battery but still recommended because we can not build a phone smart enough to know how full the battery is so the battery bar is a guess based on last time you filled the battery and ran it out. So with a new phone if you do that you damage the battery but make the battery bar more accurate. So I would not do it unless you battery bar is lying to you about how much is left.
Now here's the kicker: Do you want a battery that stays charged a long time?
You have a choice to make, for the battery is happy at a half charge so if you don't want to replace your battery and want it to hold a charge the longest you will unplug it when its 75% full and plug it back in at 25%
Think of it like breathing. When its at 50% charged it normal like your breathing now, but when full its like breathing fast and empty its like holding your breath. you can do it but its puts stress on you so you cant do it all the time. Your battery is the same if its always full it puts stress on it slowly killing cycles off and reducing battery life even if its not plugged in.
Hope this helped and this is for a lithium battery, lead and nickel are different if you need more info all the way down to battery type, size, power, amps, ect. Try to google Battery university and do read the comments they will help you understand the graphs and all if you don't at first