When your device is at rest, Doze automatically puts it into a sleep state. So your phone can still set off your alarm in the morning even if you forgot to charge it.
1. Android takes care of this for you. Doze mode is an automatic feature of Android 6.0 Marshmallow OS