This is obvious advice. When someone trains for a marathon, he/she doesn't train with people who are slower. A person who strives for improvement trains with others who have more stamina and speed. Usually, the best training partners are those who have a track record of successfully completing marathons within a reasonable (and realistic) time range. The same concept applies to growing one's ability to create good software.
My StoryRight after graduating college, I took my first position as an entry-level web developer at a small business outside of the city. Any graduate faces a steep learning curve at his/her first job. Mine was even steeper because my team lacked a senior developer to show me the ropes. I was blindly coding naive solutions to even the simplest of problems.
This continued until an experienced web developer joined the team. None of my ideas were left uncriticized, meaning I had to produce meaningful and clean code to the best of my ability. With proper guidance, I was exposed to several different approaches to solving web-related problems. Less and less I felt like I was hacking spaghetti together. Fun acronyms like AJAX, HTTP, and REST became less cryptic and my toolset grew. My code began to exhibit more elegance and efficiency. Best of all, my confidence steadily grew more and more each day.
When it was time for me to leave the company, I made it top priority to find a team with at least one developer with relatively more experience than me. This came before any other details about the job, including company perks, pay increase, technology stack, etc. No salary can pay for the amount of incompetence accrued from being stagnant and unchallenged.