Shares of Target surged Wednesday after the retailer reported unprecedented growth in foot traffic at its stores, along with second-quarter profit, revenue and comparable store sales that surpassed analysts' expectations.

The big-box retailer also said digital sales skyrocketed more than 40 percent during the quarter. Building on that momentum, it raised its earnings outlook for the full year.

"We are seeing a great consumer response ... unprecedented traffic. As we go back and look, we've never seen traffic like this," CEO Brian Cornell told CNBC's Becky Quick on Wednesday.

Target shares were up more than 5.5 percent in early trading on the news, hitting an all-time intraday high of $88.89.

The retailer has been focused on reinvesting in its business ever since it laid out a strategy at the start of last year to pour $7 billion into expanding its e-commerce platform, bulking up its lineup of in-house brands, opening new small-format stores and remodeling existing locations. Cornell said those investments appear to be paying off. Target reported its strongest same-store sales growth in 13 years.

A healthy U.S. economy, rebounding consumer confidence and record low unemployment is also benefiting retailers like Target and Walmart. The latter reported earnings last week that also topped analysts' expectations, driving Walmart shares up more than 9 percent in one day.

"I've been doing this for a long time, and I think this is the healthiest environment I've ever seen," Cornell said on "Squawk Box," referring to consumer spending.

Here's what Target reported for the three months ended Aug. 4 compared with what analysts were expecting, according to a survey by Thomson Reuters:

Adjusted earnings per share: $1.47 vs. $1.40 expected

Revenue: $17.78 billion vs. $17.28 billion expected

Same-store sales: up 6.5 percent vs. an increase of 4 percent expected

Net income was $799 million, or $1.49 per share, compared with $671 million, or $1.21 a share, a year ago. Excluding one-time items, Target earned $1.47 a share, 7 cents ahead of analysts' expectations.

Revenue climbed nearly 7 percent to $17.8 billion from $16.63 billion a year ago, again ahead of an expected $17.28 billion in sales. The company said sales of home goods exceeded its expectations, while apparel and electronics were two of the strongest categories during the quarter.

Sales at stores open for at least 12 months were up 6.5 percent, better than an anticipated increase of 4 percent and the strongest same-store sales growth at Target in 13 years. That included online sales, which grew 41 percent from the same period last year, compared with an increase of 32 percent a year ago. The retailer's massive one-day sale in July, held in-tandem with Amazon Prime Day, was a key driver for e-commerce sales this quarter, Target said.