Hi there,
It is true that not charging your battery past 80% or letting it drain to 0% all the time can extend its lifespan. It is the constant charge and discharge of electricity that wears batteries down over time. Additionally, when batteries are charged and discharged at very rapid rates, their lifespan also degrades at a faster rate. It is important to note that Apple does have some measures built into their devices which help extend the life of their batteries. As for keeping your battery charged between 40% and 80%, because there are no tools to control this, and this rule effectively limits your battery to just 40% of its total capacity, it's just highly impractical.
Yes you can extend the overall lifespan of your battery, but you'll probably find that it's not worth all the effort in most cases. I will, however, link to an Apple page which talks all about batteries, including Apple's recommendations for maximizing battery performance.
https://www.apple.com/ca/batteries/
Cheers!