The main thing that wears a battery out is discharge/recharge cycles. Letting it run down then charging it back up repeatedly will shorten it’s life considerably.
Another factor is how full you charge it. Charging to 100% causes more wear than charging to 80%.
I have my battery charge capped at 80% and I have it plugged into AC whenever I can.
The following probably applies to laptop batteries as well.
I have an app for my Android devices called AccuBattery. It monitors charge, battery voltage, charge/discharge rates, etc, and can use this to assess battery performance. It can sound an alarm at a certain recharging percentage to remind you to stop charging and recommends setting this to 80%. From the data it gathers, it derives an estimate of the wear caused by each recharge cycle.
Whenever I charge to 100%, it gives a wear value close to 1.0, for example:
42% to 100% = 0.93 wear
74% to 100% = 0.82 wear
51% to 100% = 0.92 wear
When I only charge to 80%, the wear values are much lower:
52% to 80% = 0.17 wear
49% to 80% = 0.18 wear
31% to 80% = 0.20 wear