As I understand you, your work pemit is based on the specific job you have now.
If you loose your job before time, you also loose your right to stay in Denmark legally, and thus cannot benefit from unemployment benefit.
However, if you complete your job according to your work permit, and have applied for a new work-permit before the old one expires, then you are allowed to work full time in the "waiting period" where the immigration service process your case.
In this situation you should be able to get dagpenge, until you start your new job. But please get this confirmed by your A-kasse.
If you finish your current contract without having found a new job/send application for a new work permit, then you have the right to stay in Denmark for up to six months...but the residence permit in this jobserach-period don't give you right to work.
In this situation you will not be able to get dagpenge.
But for being eligible for unemployment benefits (dagpenge) - in addition to having the necessary work permit - you must also fulfill the other requirements, which include the income requirement, membership of an A-kasse for at least 1 year, and finally you must meet the residence requirement (from January 1, 2019).
You can read more about these requirements here: