IMO the biggest takeaway I had after a layoff: Always try to navigate your career so that you are doing something valuable to the business. You can tell based on a lot of clues whether you're in a position that's valuable or if you're forgettable. Moving "toward the money" not only helps job security but it helps your compensation too.
Say for example your team has a stretch of a few months without any new high priority requirements or requests. A young developer might think, "Yay, finally we have enough time to do all that refactoring in the backlog." But in reality, that situation should make you very concerned.