There's a lot of conflicting information about how to properly care for a lithium-ion battery (the kind of battery that is in your smartphone). There are basic things we know are bad for batteries, including extreme temperatures (hot or cold), overcharging, and complete discharging. Fortunately modern devices, including all smartphones today, are built to protect the battery automatically. For example, your phone will shut down before the battery is completely depleted, and it won't allow it to overcharge either. But there are some things that can help prevent the battery from dying prematurely.
There are multiple ways a lithium-ion battery can age. First of all, Lithium-ion batteries have a finite number of charge "cycles". In other words, how many times the battery can be fully charged and fully drained. Manufacturers usually say batteries have between 300 and 500 cycles. The depth of the discharge matters as well, so it's best to charge the battery as often as possible between uses. A partial discharge is fine for lithium-ion, there is no 'memory' and the battery does not need to be fully discharged periodically. Heat plays a role, too. If a battery is kept in excessive heat (over 86 degrees) and in a full state of charge, that will diminish its overall capacity at a faster rate than discharge cycles.
In general, the best thing to do is keep your laptop or phone plugged in whenever possible in a cool environment. If you're interested in battery longevity, it's also best to avoid using fast-chargers. For more detailed information on how lithium-ion batteries wear, check out this article from batteryuniversity.com.