Target's business is booming thanks to the retailer's investments to make it as easy as possible for shoppers to buy things online and get them that same day.

When Target reported quarterly earnings on Wednesday, it said digital sales surged 31%, with its same-day services accounting for 80% of that growth. Those services include a curbside pickup option, same-day delivery via its Shipt network and buy online, pick up in store.

It has been a concern among analysts and investors when retailers, including Walmart, have started selling more online, because those sales are less profitable and require heftier costs to get those orders to customers' homes. Walmart is still losing money online. But Target says it has found a way to slash costs and make money.

"When it's delivered by our stores ... those look a lot more like store economics," CEO Brian Cornell said during an interview on "Squawk Box" with CNBC's Becky Quick.

He said when Target fulfills an online order from the back of its stores versus shipping from a distribution center, "about 40% of the cost goes away." He said when customers order online and pick up at a store, use curbside pickup or select shipping via Shipt, "about 90% of the cost goes away."

"We certainly like that," he said.

Walmart has likewise been adding in-store pickup for grocery orders, which is now available at 3,100 stores.

Arguably, this is the one area where Amazon can't compete at the same size and scale. It doesn't have a network of stores, like Target and Walmart, where shoppers can pick up orders. But it has been adding Amazon lockers to its Whole Foods grocery stores and shopping malls.

Target said Wednesday its net income rose 15.5% to $706 million during the latest period ended Nov. 2, up from $616 million a year earlier.

The company also raised its full-year profit outlook, now expecting full-year adjusted earnings per share to fall within a range of $6.25 to $6.45, compared with a prior estimate of $5.90 to $6.20. Analysts had been calling for earnings per share of $6.18.

Target shares surged more than 10% in premarket trading following its report, putting the stock on pace to open at a record high.