While many retailers are struggling to attract shoppers to their stores, consumer electronics retailer Best Buy (NYSE:BBY) seems to have cracked the code. Best Buy blew past analyst estimates for both revenue and earnings when it reported its second-quarter results before the market opened Tuesday. Comparable sales grew at the fastest rate in a long time, online sales growth accelerated, and profits soared.

There's a lot to digest in Best Buy's report, but here are five key numbers that investors should focus on.

Customers lining up outside a Best Buy store.

Image source: Best Buy.

1: 5.4%

The headline number for Best Buy was its comparable sales growth, which came in at 5.4%. That compares to just 0.8% growth during the same period last year, and 1.6% growth during the first quarter. In the domestic segment, all of Best Buy's product categories produced comparable growth, with entertainment sales surging 15.4%, computing and mobile phone sales jumping 6.7%, and appliance sales rising 5.8%.

Best Buy CEO Hubert Joly explained what drove this better-than-expected growth:

Our higher-than-expected comparable sales of 5.4% were driven by stronger consumer demand for technology products and by the strong execution of our strategy. Against a backdrop of continued healthy consumer confidence, we believe broad-based product innovation is resonating with consumers and driving higher spend. And, with our effective merchandising and marketing activities, combined with our expert advice and service available online, in-store and in-home -- we are garnering an increasing share of those dollars.

Best Buy's results may be getting a boost from a competitor throwing in the towel. HHGregg, a chain of 220 consumer electronics, appliance, and furniture stores, went out of business earlier this year. The initial liquidation of merchandise may have been a headwind for Best Buy, but one fewer competitor should be a positive in the long run.

2: 31.2%

One thing driving Best Buy's strong comparable sales growth was the e-commerce business. Best Buy managed to grow domestic online sales by 31.2% year over year during the second quarter to $1.1 billion, up from 23.7% growth during the same period last year. As a percentage of the electronics retailer's total domestic revenue, online sales accounted for 13.2%, up from 10.6% in the prior-year period.

One of the pillars of Best Buy's successful turnaround over the past few years has been growing the e-commerce business. The company made its prices more competitive, revamped its website, and began shipping online orders from its stores to both speed up delivery times and improve product availability. The payoff has been consistent double-digit growth.

It should be noted that Best Buy produced this online sales growth during the quarter that contains Amazon's annual Prime Day event, in which the e-commerce giant offers a deluge of deals in a wide variety of product categories. While Prime Day boosted Amazon's revenue, it had no discernible negative effect on Best Buy's results.

3: 21%

While Best Buy's revenue grew at a mid-single-digit rate, the bottom line expanded even faster. Non-GAAP diluted earnings per share came in at $0.69, up 21% compared to the prior-year period. Higher revenue was the main driver, while lower operating expenses as a percentage of revenue and share buybacks helped the cause. As part of its $3 billion ongoing share-buyback program, Best Buy spent $398 million in the second quarter alone buying back shares.

Gross margin slipped 10 basis points year over year to 24.1%, but this decline was overwhelmed by higher revenue. Operating margin jumped 20 basis points year over year to 3.6% thanks to slow-growing operating expenses.

Best Buy has succeeding in cutting much of the fat over the past few years, so cost-cutting to drive earnings growth will be more difficult in the quarters ahead. It will take sales growth, like what we saw during the second quarter, to keep the bottom line moving higher.

4: $3.5 billion

Despite spending hundreds of millions of dollars each quarter on share buybacks and dividends, Best Buy still sports a pristine balance sheet. The company had $3.5 billion of cash and just $1.35 billion of debt at the end of the second quarter, good for a net cash position of $2.15 billion. That's up slightly from the prior-year period.

Best Buy boosted its cash reserves over the past few years by selling off international businesses to focus on its core domestic market. Thus, the company not only got out of markets where it wasn't performing well, but it built a cushion of cash, which gives it room to implement its turnaround strategy while continuing to return cash to shareholders.

At a time when the retail industry is going through big changes, retailers that have avoided loading up on debt will be more likely to survive and thrive. Best Buy's fortress balance sheet should allow it to weather just about any storm.

5: 4%

Comparable sales growth around 5% probably won't be the norm going forward, but Best Buy increased its full-year guidance to reflect its strong results. The company now expects to grow total revenue by 4% in fiscal 2018, up from previous guidance calling for 2.5% growth. "The increased topline expectations are being driven by the anticipation of continued positive industry and consumer momentum, coupled with the impact of product launches," said Best Buy CFO Corie Barry.

Guidance for the bottom line was also raised. The company expects non-GAAP operating income to grow by 4% to 9%, up from a previous range of 3.5% to 8.5%. An extra week this fiscal year will be responsible for some of this growth, but Best Buy still expects non-GAAP operating income to grow by 2% to 6% on a 52-week basis.

The upcoming launch of new iPhones later this year is one reason for Best Buy's rosy outlook. Expectations are high that Apple will produce innovative new products, and if the tech giant delivers, Best Buy stands to benefit.

Timothy Green owns shares of Best Buy. The Motley Fool owns shares of and recommends Amazon and Apple. The Motley Fool has a disclosure policy.