At 39 years old, Marissa Mayer is the CEO of a $40 billion company.

In terms of personal wealth, she’s made at least $500 million. That’s $300 million at Google and another $200 million or so at Yahoo.

How did she put together such a successful career so quickly?

That’s one of the main questions I answer in my new book, “Marissa Mayer and the Fight to Save Yahoo!”

(For sale on Amazon.)

The book spends several chapters telling Mayer’s life story, and how she gained stunning wealth and worldwide fame at Google.

Here are five lessons you can learn from Mayer.

1. Choose the opportunity that’s scariest. When Mayer was finishing her graduate program at Stanford, she had a world of career options in front of her. She could have become a high-paid consultant. She could have become a professor at Carnegie Mellon. Or, she could join a tiny, money-losing startup with a funny-sounding name. Mayer interviewed at the startup and was blown away by how many smart people were there. They were so smart it almost intimidated her. Because the startup was risky, and because its people were so smart, going there was, for Mayer, the scariest option — which is why she went with it. That startup? Google. Mayer was one of its first 25 employees.

2. Recognize your relative weaknesses. Mayer was hired by Google as a coder. Her first big project was to build Google’s advertising system. It took her months and months to make any progress. Then Google went out and hired a star coder from DEC named Jeff Dean. Dean came into Google and built the system Mayer was trying to build in a matter of weeks. Mayer, who already decided she loved working at Google, realized she wasn’t going to make her mark there as a coder. She would have to find other ways to be useful.

3. Identify your company’s problems and solve them. After Mayer realized her future at Google was not as a coder, she decided to make herself useful by throwing herself at whatever problems the company needed to solve. She worked in marketing. She rigged servers. She helped PR. Finally, Mayer found three areas where she could materially improve Google. She ran Google CEO Larry Page’s staff meetings. She became the person who said whether new products had user interfaces that lived up to Google’s standards. Eventually, this turned into a job where Mayer became the final authority for how all Google products, including search, looked and felt. Finally, she launched the associate product manager program at Google — a training program where students with high technical skills are taught to manage. The people in this program, called APMs, were spread throughout Google. Through them, Mayer gained great influence and prestige at the company, as each reported to their day-to-day bosses and to her.

4. Don’t worry too much about stepping on toes. Throwing herself at all these problems, Mayer would sometimes throw herself at problems that other people were already trying to solve. Often, these people would get upset that Mayer was stepping on their toes. Mayer didn’t care. More important, Google management didn’t care. They were just happy Mayer fixed some of the issues plaguing Google when it was a startup. Mayer made some enemies at Google, but she also made hundreds of millions of dollars and turned herself into a business celebrity.

5. Know when to say goodbye. In my book, I tell the story of how, eventually, Mayer’s enemies at Google grew so powerful that they were able to have her sidelined. Mayer could have quit in a huff then but she did not. Instead, Mayer continued to do good work for Google in a lower-profile role. She led the development of the Google Maps app for iPhone, for example. Mayer also did not rush into the Yahoo CEO job. When Yahoo CEO Carol Bartz was fired in 2011, a friend of Mayer’s told her she should consider that job. Mayer said she had, but that she thought the company’s board of directors was too unreliable to work for. Months later, that board was almost entirely gone after it lost a battle with activist investor Dan Loeb. When Loeb reached out about the gig, Mayer was interested. She soon signed a $200 million deal.

For more on how Marissa Mayer became so rich and successful at such a young age, read “Marissa Mayer and the Fight to Save Yahoo!”