The only point of consensus in this year's otherwise deeply polarized election seems to be that increased wage and job competition created by globalization has decimated the American middle class. Bernie Sanders, a socialist, proclaimed repeatedly during his failed Democratic presidential bid, "The global economy is not working for the majority of people in our country." Meanwhile, Donald Trump, a capitalist and the successful Republican presidential nominee, insists, "Globalization has wiped out our middle class."

They are both wrong. The American middle class is still standing after the economic shocks it absorbed over the last decade, and it is thanks to globalization.

Globalization's two key elements are trade and immigration. Trade has buffeted the American middle class by letting it import riches from abroad, and immigration by generating them from within.

French economist Thomas Piketty, in his 2013 magnum opus Capital in the Twenty-First Century, popularized the notion that the American middle class was hollowing out. His basic thesis was that the rich were getting richer and the poor poorer because the returns on capital, the factor of production that the rich owned, were outpacing the returns on labor, the factor of production that workers owned. So rising productivity wasn't translating into higher wages, widening the income gap. Although Piketty had to somewhat retract his findings after a barrage of scrutiny debunked some of his data, pundits on both the left and the right have seized on his ideas to blame globalization for decimating working-class wages and jobs by increasing the returns on capital over labor.

That's a plausible hypothesis — but ultimately false.

For starters, notes Manhattan Institute's Scott Winship, the American working class is stable. (His four-part series in Forbes earlier this year dissecting the various arguments and data deployed by inequality-narrative peddlers is well worth a look.) He notes that the rate of increase of median wages of workers has certainly slowed since the 1970s. But that isn't because workers aren't being fairly compensated for their productivity contributions. Rather, he points out, the labor market entered a period of prolonged correction after powerful unions artificially bid up wages for several decades in the post-World War II era. There were other factors too, but realistic calculations show that today's wages, earnings and income — individual and household — are stuck at 2000 levels, he says. "That sounds bad, except that in 2000, the American middle class was richer than it had ever been, and essentially the richest middle class in global history," he maintains.

That is not a bad place to be given how much this country has endured since 2000. The 9/11 attacks, for starters, triggered $7.6 trillion in war and homeland security spending, about $2 trillion on the Iraq and Afghanistan wars alone. The country was still reeling when it went into a financial meltdown that induced the housing crash and the Great Recession, wiping out about $16.5 trillion of household net worth from its peak in 2007. And this does not even count the trillions of dollars in wasteful government spending on unproductive projects to stimulate the economy.

Nor have President Obama's grand social designs been cheap for America's middle class. ObamaCare's cost to middle-class families without employer coverage or subsidies is over $10,000 annually in forced premiums, taxes, and other costs. That by itself is enough to offset at least part of the $18,000 annually that the Economic Policy Institute says inequality is costing middle-class households. (Read Winship for why that's a grossly exaggerated figure, by the way.) And then there is the cost of the unparalleled expansion of the regulatory state under this president. The Heritage Foundation estimates that President Obama's new regulations cost the economy $108 billion annually. Total regulatory costs, which are borne disproportionately by the middle class through lost jobs and higher prices, now exceed a whopping $2 trillion annually — more than is collected in income taxes each year.

There isn't an economy in the world — now or ever — that could have endured such massive blows without a major hit to its people. But the worst that has happened in America is stagnant wages. Remarkably, our quality of life has continued to improve.

One big reason is that globalization has given America foreign-born tech workers without whom the Information Revolution is unimaginable. They run almost half of Silicon Valley's startups, transforming the way Americans live, play, work, and conduct business. Some years back, Reason.tv interviewed random people on the street and asked them if they'd give up the internet for a million dollars. It was hardly a scientific poll, but there were no takers. And with good reason.

The internet has not only put free music, social media, and entertainment at everyone's finger tips, but free e-platforms that have radically lowered the costs of doing all kinds of business. Over two million independent merchants sell their wares on Amazon without any major marketing expenditure of their own. Over 6 percent of retail in America is conducted via e-commerce and is projected to touch 20 percent by the end of the decade. AirBnB, the homesharing service, and Uber, the car service, have allowed people to turn their personal effects into money-generating assets, boosting middle-class incomes. The vast majority of AirBnB hosts in Chicago have household incomes of less than $100,000. And the typical Uber driver is married with kids, with a bachelors degree and a car that he uses to supplement a full- or part-time job with a gig that rakes in, on average, $400 a week from 15 hours of driving. Over the last two years, Uber drivers in Chicago have earned more than $250 million.

These IT-powered opportunities certainly cushioned the blow of the exogenous economic shocks to the American middle class. But what's also helped maintain — indeed, vastly improve — Americans' standard of living is the other key ingredient of globalization: free trade. That has radically slashed the cost of production both in terms of dollars and time, putting even luxury items within the grasp of ordinary people.

St. Lawrence University economist Steve Horwitz examined the consumption patterns of Americans post-9/11 in 2014 and found that for virtually every good — washing machines, computers, cell phones, and so on — the consumption gap between the rich and poor diminished between 2003 and 2005. It is possible that the economic downturn since then reversed some of these gains, but hardly all. This is not surprising because the number of work hours required to purchase the bundle of goods that the poor consume has been steadily going down. Consider color TV: In 1973, when median wages were still rising at a healthy clip, it would have required 127.8 hours of work to purchase a TV. In 2013, it took a mere 20 hours.

To be sure, none of this means that everyone in America has it easy in a globalized economy. Much of the white working class in Appalachian America is trapped in poverty and despair. But retreating into a narrow nationalism, as many smart-set conservatives and liberals worried about the middle class are increasingly recommending, would be a big mistake for the very people they want to help.