Modern
laptop batteries are Lithium-Ion (Li-ion) and are considered to be consumables - they do wear out and will need to
be replaced, normally after a few years - but you can help to preserver their life.
Note that the following only applies to this type of battery and only to their use in laptops. Mobile phones will likely also be using this type of battery but they run at a much lower current demand and so the stress on the battery is much less than for a laptop.
The biggest killer for this type of battery is heat (and that does apply to mobile phones!)... hot or cold, so don’t expose your battery
to extremes of heat – room temperature is good. Beware of leaving your laptop in a hot car and always ensure it has good ventilation when in use.
Don’t leave
it discharged for long periods of time. This will get it into a state where recharging it by normal means just won't work. If you’re not going to use it for a
few weeks, charge it to around 50% and then take it out of the laptop. This would apply particularly to schools and colleges during long holidays.
In normal use it is better for it to run on the battery until it has dropped to, say 30%-50%, and then recharge it. This places less stress on the battery than fully discharging and recharging it. Running continually charging is also not a good idea - it will cause the battery to have capacity loss so that it won't be able to hold as much charge. If you want to run it
plugged in all the time, take the battery out.
Every month
or so let it fully discharge and then recharge it to recalibrate it. This allows computer systems (for example) to get more accurate information as to the state of the battery and close down at the right moment.
Finally, if you have a spare battery consider the above points. If it's normally not in use then it should be charged to around 50%, however better would be to keep swapping the batteries over so they are both getting proper use and charge cycles.