So much for all those worries that Walmart was losing ground to Amazon.

Walmart delivered its best US sales growth in more than a decade, and digital sales surged 40%.

Some analysts were worried that growth in Walmart's numerous digital operations, including Jet, ModCloth and Moosejaw as well as Walmart.com, were starting to slow.

But a stellar earnings report Thursday may put those fears to rest. Moody's lead retail analyst Charlie O'Shea called it "a banner quarter on multiple fronts."

Overall sales at US stores open at least a year rose 4.5%. Walmart (WMT) also raised its outlook for the year.

The stock soared 9%, helping the Dow to a gain of almost 400 points, its best showing in four months.

Walmart's Sam's Club warehouse unit, a competitor of Costco (COST) and BJ's Wholesale (BJ), reported same-store sales growth of 5%, the best in six years.

And Walmart reasserted itself as a leader in the supermarket business. It has battled for market share with Amazon and its Whole Foods unit, as well as supermarket leader Kroger (KR).

But Walmart's grocery sales growth was one of the highlights in the quarter. Walmart CEO Doug McMillon vowed that Walmart will continue to "aggressively roll out grocery pickup and delivery in the US."

Moody's O'Shea liked that news, too. He said Walmart's food business "continues as a bright spot, with rapid rollout of in-store pickup well underway, and product delivery expanding as well."

Walmart's results may also help reassure investors after disappointing sales from Macy's (M) on Wednesday led to a retail sector bloodbath. Many prominent retail stocks plummeted more than 10%.

Shares of Target (TGT) rose Thursday. Costco was higher, too. So were shares of Nordstrom (JWN), the high-end department store chain which will report earnings after the closing bell Thursday.

But JCPenney (JCP) shares plunged more than 25% to below $2 a share after the struggling department store company reported a bigger than expected loss and yet another steep decline in sales.