It's almost certain that sometime during your lifetime you will lose your job, often unexpectedly and for no reason other than the company is cutting its workforce. While you are working, there are things you can do to try and prevent this, such as working hard, getting along with managers and coworkers, improving your skills, seeking new challenges, and maintaining a great attitude. Ultimately, though, it may happen to you and you need to be prepared.
First, it's important to have an emergency fund with enough cash to cover three to six months of living expenses. Although this won't alleviate the potential pain of being laid off or even fired, it will help immensely in avoiding the financial suffering that many will face when this type of unexpected event occurs.
Second, take a breath, cry if you need to, scream if you have to, and then realize that what's done is done, and nothing more can be done about it except to learn from the event and be better prepared next time.
Third, file for state unemployment benefits (check the links below). Although they won't be enough to cover all your expenses, they can help with the rent or mortgage, and this can buy you time to find another job.
Fourth, once you know what your benefits will be, take stock of your financial situation and tighten the budget where needed.
Fifth, work on your resume, contact your network of friends and family both for support and assistance, and check all the resources that you can find. There are lots of websites where you can research jobs, and post your resume. Additionally, each state has a website dedicated to helping you obtain your benefits, and search for new opportunities. Check out the links below for your particular state.