Everyone who works under IT sector will one day face what so called as a Layoff.
Though we can't escape from its clutches yet few steps can buy us some time.

Show you are important:

When we hear about layoffs our natural instinct will be to become invisible from the eyes of HR.
But that wouldn't help. It will only grab attention.
You may be forced to do extra work and works which are inferior to your qualification.

Key idea is to represent yourself as a person without whom the company can't run.

Stay updated & have a wide skill set:

No company can afford to hire an outdated programmer. That's why you must be updated with the latest technologies and acquire skills that are currently needed in this field.
People who have wider knowledge in different departments within the company are more likely to survive layoffs than people with a narrow skill set.

Try staying there:

Higher the salary the more likely you get fired unless you are important to the company.
We try to jump off into another company when we hear the news that layoff is about to begin.
But it has demerits. Since you are a new employee there is a high possibility that you may get
fired when layoff hits that company.

Try staying in the same company either by reducing your salary pay (If possible) or by switching departments.

Team player:

Don't be the odd one. Mingle with everyone and maintain a positive outlook as much as possible.
Maintaining a friendly relationship with HR is good for your career.

Let your accomplishment talk:

If the company recognizes you as a hard worker, they can't afford to lose you.
When you put your best efforts more people will be there to support you.

Anyways the judgment day will come for sure.
Don't panic. If you could arrange a letter from HR regarding your layoff it will be quite useful.
That letter supports you by stating that you lost your job during a layoff and not intentionally fired.
This can support your resume in the next company you wish to apply.

Finally, I would like to say that whatever happens is for the best.
In our country, we are paid high to forget our dreams.

But if you identify what is your potential and make efforts to attain it surely you will enjoy your work with job security for a longer period of time.