Former President Barack Obama struggled with the result of the 2016 presidential election, which ended in victory for President Donald Trump, according to The New York Times' review of the upcoming memoir by Obama advisor Ben Rhodes.

In "The World as It Is," Rhodes wrote that Obama endured a series of emotions following Trump's election and focused on cheering up his staff before sinking into disbelief.

Rhodes wrote that Obama was shocked that Americans elected a "cartoon."

"I've got the economy set up well for him," Obama said. "No facts. No consequences. They can just have a cartoon."

The economy significantly improved under Obama, who took office during the financial crisis. The unemployment rate peaked at 10 percent in 2009, Obama's first year in the White House, but it had fallen to 4.7 percent by the time he handed power to Trump. Stock markets also bounced back dramatically, and there were 75 consecutive months of job growth.

Under Trump, the unemployment rate fell to 3.9 percent in its most recent reading, the lowest point since 2000.

Rhodes also wrote that Obama's aides assured him that Obama would have won the election if he were permitted to run for another term, saying he had more in common with the next generation than Trump. However, this didn't seem to cheer up Obama, who wondered whether his presidency came 10 or 20 years too early, according to the book.

Trump has publicly blasted many of Obama's policies, including protections for children brought to the U.S. illegally, trade deals and the Iran nuclear deal, from which Trump recently withdrew. He has also sought to undo many of Obama's policy achievements, such as the Affordable Care Act.

After Trump's election, Obama reportedly said: "We're about to find out just how resilient our institutions are, at home and around the world."

"The World as It Is" is set for release on June 5.

The White House and the office of Barack and Michelle Obama did not immediately respond to CNBC's requests for comment.

Read The New York Times' full report.