Of course that depends on the battery, but Lithium Ion batteries were the standard for laptop/cellphone batteries last time I checked.
A battery feels most happy
- being neither too full nor too empty,
- being not too hot,
- being not charged/recharged too often.
If you don't need the battery, remove it from the battery pack (at about 60%) and store it dry and cool.
If you use the battery, make sure your laptop doesn't get too hot. Usually the processor is located near the "top" of the keyboard, away from your hands, but so is the battery.
There is power management software for many laptops, which ensures that your battery only gets charged once the charge falls under a certain threshold (e.g. 40%) and then charges up to 80%. This allows you to plug in/unplug your laptop (to move location) without initiating a new charge cycle, which would lower the life span of the battery.
(A friend of mine had a broken adapter, so the battery was charged/discharged every time someone bumped into the chord. After a few months, the 2-year old battery now lasts at most 2 minutes!)
For cellphones, it's inconvenient to keep them plugged into the wall all the time, so the general guideline is usually to charge it once it falls under, say, 30% and discharge it fully, followed after a full recharge, about once a month. The same holds true for laptop batteries, of course, but I usually find myself discharging them fully more than once a month anyway.
In particular, this means that the rule (myth?) "fully discharge before charging", which applied to old nickel-cadmium rechargeable batteries, does not apply to modern laptop/cellphone batteries.