Walmart on Tuesday reported earnings and revenue for the holiday quarter that topped analysts' expectations, as its e-commerce sales surged 43 percent thanks to more shoppers using its online grocery delivery service and spending more per trip.

CEO Doug McMillon said "a favorable economic environment" has been helping Walmart grow sales and take market share from rivals, including in food and toys.

Walmart beat after dismal December sales data released by the Commerce Department last week put a damper on the retail industry and sparked some concern that Walmart also suffered during the holidays. But the retailer's results on Tuesday show shoppers continued to flock to its stores. Walmart also benefited from food stamps being released early because of the partial government shutdown, giving sales a last-minute boost.

"To us, the consumer looks like they're in pretty good shape," CFO Brett Biggs said. "Gas prices are down. ... We're always monitoring the consumer and are ready to act if things change, but we feel our guidance is good for the next year and our business model works well in most environments."

The company said it's maintaining its sales outlook for 2019, as it raised its annual dividend — payable to shareholders on April 1 — by 2 percent to $2.12 per share, up from $2.08 a share.

Walmart shares were up more than 4 percent, trading around $104, Tuesday morning on the news.

Here's what the retailer reported for the fourth quarter of fiscal 2019 compared with what analysts were anticipating, based on a survey by Refinitiv:

Earnings per share, adjusted: $1.41 vs. $1.33 expected

Revenue: $138.79 billion vs. $138.65 billion expected

Same-store sales in the U.S.: up 4.2 percent vs. growth of 3.2 percent expected

Walmart reported net income for the quarter ended Jan. 31 of $3.69 billion, or $1.27 per share, compared with $2.18 billion, or 73 cents a share, a year earlier. Excluding one-time items, Walmart earned $1.41 per share, 8 cents ahead of analysts' expectations based on a survey by Refinitiv.

Revenue climbed nearly 2 percent to $138.79 billion from $136.27 billion a year ago. That came in ahead of expectations of $138.7 billion.

Sales at Walmart stores in the U.S. operating for at least 12 month were up 4.2 percent, topping expected growth of 3.2 percent. The company said traffic at stores was up just 0.9 percent during the quarter, compared with growth of 1.6 percent a year ago. The average shopper's ticket, however, grew 3.3 percent. A year earlier, the average ticket was up just 1 percent.

Online sales were up 43 percent during the fourth quarter, matching growth during the previous quarter. Walmart said that for the year, it achieved e-commerce sales growth of 40 percent, which it had been targeting. The company has been investing heavily in adding more products — like celebrity-inspired apparel and high-end camping gear — to its website in order to achieve that target and compete with Amazon. It's also been on a buying spree of online brands like Art.com and lingerie retailer Bare Necessities.

Walmart didn't change its sales outlook for fiscal 2020 from last October. Net sales growth is predicted to be at least 3 percent, hurt by deconsolidation of Walmart's Brazil operations and reduced tobacco sales at Sam's Club. Walmart still expects net sales to climb about 5 percent internationally.

Walmart is still calling for U.S. same-store sales to rise 2.5 to 3 percent for the year. Fiscal 2020 operating income is expected to decline slightly.

The company is targeting e-commerce sales growth of 35 percent for fiscal 2020, which won't be as robust as what it was able to achieve last year. Walmart said Tuesday it will spend the most money on store remodeling, e-commerce initiatives and bulking up its supply chain in 2019.

"Our fulfillment shipping costs are improving as we continue to enhance our [online] assortment," McMillon said on a call with analysts and investors. "Repeat visits should increase and contribute to improving profitability."

As of Friday's market close, Walmart shares were up about 7 percent this year, bringing the retailer's market cap to about $290.5 billion. That's compared with rival Target, which has watched its stock climb about 9 percent this year, bringing its market cap to $37.7 billion.

Target and Amazon shares were both up roughly 1 percent Tuesday morning, on the heels of Walmart's upbeat earnings report.