What happened

J&J Snack Foods (JJSF 1.03%) shareholders beat the market this week. The stock gained 11% through Thursday trading compared to a 1.1% decline in the S&P 500, according to data provided by S&P Global Market Intelligence. That rally helped extend the packaged foods specialist's 2022 outperformance. The stock is down just 1% so far this year compared to a 17% decline in the wider market.

It was sparked by an earnings report that was well received on Wall Street.

So what

J&J Snack Foods said in a Monday earnings announcement that sales jumped 24% in the fourth-quarter selling period, which ended on Sept. 24. That result marked an acceleration over the prior quarter's 17% increase and reflected strong demand for its food products, including pretzels, churros, and frozen beverages. "We are pleased with our strong top-line growth across all three of our business segments," CEO Dan Fachner said in the filing.

It wasn't all good news in the report, though. J&J Snack Foods reported weaker profitability thanks to rising costs. Adjusted operating earnings fell slightly in the period even though sales jumped.

Yet inflation took a smaller bite out of earnings this quarter than in the previous quarter, raising hopes that the worst could be over when it comes to shrinking profit margins.

Now what

Investors will want to follow profit margin and sales growth trends in the next few announcements, especially as the company raises prices in 2023. But J&J Snack Foods is seeing strong demand for its products despite extra financial stress on many consumers, and it is boosting revenue quickly without spending more on marketing.

These factors help explain why the stock trounced the market this week and is beating the S&P 500 so far in 2022. Worries about a recession on the way have been eased by the company's ability to show steady growth into late 2022.