Wal-Mart (WMT 0.09%) continues to defy expectations. In the recently reported third quarter, it posted EPS (excluding items) of $1 a share and revenue of $123.18 billion, topping analyst expectations of $0.97 and $121 billion, respectively. Perhaps more importantly, Wal-Mart increased same-store sales in the U.S. by 2.7% versus expectations of 1.8%; it was Wal-Mart's 13th quarter in a row growing same-store sales.

This isn't your father's Wal-Mart. And if you're not paying attention, you may be missing out on a great opportunity.

Person holding a credit card and a smartphone while sipping a latte.

Image source: Getty images.

Wall Street got this wrong

Wal-Mart's revival can be traced back approximately two years, to the company's 2015 third-quarter report. CEO Doug McMillon told investors the company was investing $1.5 billion in wages, training, and e-commerce, and that this would lead to an EPS drop of 6% to 12% in the following year. In response, shares of the stock sold off approximately 10%, the steepest one-day decline for the company in 25 years.

At the time, an analyst at Edward Jones summed up Wall Street's skepticism by noting: "The guidance is very disappointing. What if these investments don't lead to better sales, that's the biggest question." (For the record, I have repeatedly written about the need for Wal-Mart to invest in its employees to grow.)

In a testament to how myopic Wall Street is, the stock has since rallied 62% versus the 29% gain of the S&P 500:

WMT Chart

WMT data by YCharts.

How did Wal-Mart get its mojo back?

Investment in wages and training has led to cleaner stores and a better consumer experience. Before the announcement, only 16% of Walmart stores were meeting internal customer service goals. Last year, that figure had jumped to 75%. Look for those numbers to continue to rise as the company's new Walmart Academy will have trained nearly 250,000 employees by year-end.

Perhaps the biggest reason for the turnaround is the company's new, competitive digital strategy. After paying approximately $3.3 billion in a cash-and-stock deal for e-commerce company Jet.com, Wal-Mart appointed founder and CEO Marc Lore as the head of both Jet.com and Walmart.com. The acqui-hire is paying off: In the third quarter, digital sales increased 50%, with the vast majority of the increase coming through Walmart.com, according to McMillon. Look for strong online growth to continue.

Has Wal-Mart ran too far?

Still, it's reasonable to ask if shares of Wal-Mart have come too far too fast. That's an especially pertinent question in light of the challenges in the retail industry: Approximately 20 retailers have filed for bankruptcy protection this year. Additionally, through the first three quarters, the company's operating income is 3.6% lower than last year's due to increased cost of sales (product selection, or mix) and the investments in employees (wages and training). (A GAAP-earnings comparison is a poor proxy this quarter because of non-operational expenses from debt extinguishment.)

However, shares of the megaretailer are not currently overvalued on a relative basis. The company trades mostly in line with the S&P 500 in terms of both trailing and forward price to earnings, which suggests the rally is not due to high (and potentially unreasonable) expectations.

One thing is clear: This isn't your father's Wal-Mart. Look for the company to continue growing its digital channel, improving the in-store experience, and pleasantly surprising investors.