It’s all about the treasure hunt.

That’s the shopping experience at the core of TJX Cos., which owns T.J. Maxx, Marshalls, HomeGoods and other off-price retailers, where consumers search for a constantly changing assortment of brand-name apparel, furnishings and other goods at discount prices.

Shoppers love the hunt, especially during the holiday season, and it’s a key reason why TJX is thriving with its thousands of bricks-and-mortar stores while many other chains have struggled with the shift to online shopping.

“You can’t beat the prices; they have a good assortment and they carry designer brands,” said Maria Raygoza, 40, of El Monte, Calif., as she left a Marshalls store in nearby Monrovia recently with two large bags full of pottery, towels and jeans. “It’s kind of hit or miss sometimes at Marshalls, but when you do find those items, it’s worth it.”

Retailers such as Macy’s Inc. and J.C. Penney Inc. have closed stores and otherwise restructured to survive the onslaught of e-commerce, and Sears Holdings Corp. recently filed for bankruptcy.

Yet TJX — with annual sales of $36 billion, more than Penney and Kohl’s Corp. combined — has kept growing steadily with only a small online presence. About 2 percent of TJX’s sales come from e-commerce, analysts estimate.

TJX also has expanded largely under the radar, in part because the company, led by Chief Executive Ernie Herrman, prefers to keep its strategic plans and operating methods close to the vest. Its executives seldom give media interviews, and they declined to comment for this article.

But TJX’s appeal to customers and Wall Street is clear.

“This is one of the best management teams that I’ve come across,” said John Morris, senior brand apparel analyst at the investment firm D.A. Davidson & Co. “They really know what they’re doing.”

The company has posted positive annual same-store sales gains — that is, sales at stores open at least one year — for 22 consecutive years amid rapid expansion. Dividends have risen for 21 straight years. While other retailers were shuttering thousands of stores in the last two years, TJX’s store count rose 13 percent in that span to 4,070 locations worldwide.

The result: TJX’s stock price has soared ninefold over the last decade (after adjusting for its latest 2-for-1 split Nov. 6), compared with a threefold increase in the benchmark Standard & Poor’s 500 index.

Ross Stores Inc., a Dublin, Calif.-based rival in the off-price, branded-merchandise segment, has enjoyed similar success. Ross operates 1,483 Ross Dress for Less stores. Its sales hit a record $14.1 billion last year, and its stock price has surged 11-fold over the last decade.

TJX is based in Framingham, Mass., but its largest market is California, where it operated 143 Marshalls stores, 117 T.J. Maxx outlets and 78 HomeGoods stores as of Feb. 3, according to the most recent figures TJX makes available.

TJX’s buyers garner items from 20,000 vendors worldwide, many of them familiar brand-name sources such as Nike, Steve Madden and Ralph Lauren. The firm’s logistics team rushes to get the products to the stores to keep up with the outlets’ rapid turnover of inventory. Store managers hustle to quickly change their floor space for the seasons and to promote the most popular and relevant items.

“From our standpoint, the stores seem full of the best brands/products that the company has ever carried,” analyst Daniel Hofkin of the investment firm William Blair & Co. said in a recent note to clients.

Cruise the aisles at a Marshalls, for instance, and there’s a Ralph Lauren men’s casual shirt for $12.99, Betsey Johnson purses at $24.99 and a set of Bluetooth speakers at $19.99.

“I bought some Calvin Klein towels — the hand towels were $5 and the bath towels were $10,” Raygoza said.

And forget the antiquated notion of T.J. Maxx or Marshalls mainly as a dumping ground for brand-name goods that were slightly flawed, and thus couldn’t be sold at full-price department stores. TJX is now effectively a key channel for brand-name merchandise, even if the brands prefer to be discreet about using an off-price channel, analysts said.

“The flawed merchandise story was 20 years ago,” said Ronald Hess, an associate professor of marketing at William & Mary’s business school. “This is now a monster retailer, and they (quickly) turn over their merchandise more like a grocery store than a department store retailer.”

It’s all about enhancing the shopper’s desire to find a product they want at a relatively low price, or “the fundamental strength of our off-price treasure hunt,” as Herrman described it to analysts last month.

Just ask Jan Harding, 63, of Monrovia. “I come here all the time, to see what they have,” Harding said after buying olive oil, gift boxes and Christmas stocking stuffers at the Marshalls in Monrovia.

“And I always buy more than I intended,” she said. “Their clothes — you can’t beat the prices for kids’ clothes.”

The same formula applies to TJX’s HomeGoods unit, which started in 1992 and now comprises 667 stores nationwide. The stores offer a variety of furniture, rugs, cookware and lighting, and HomeGoods’ sales last year reached $5.1 billion.

TJX isn’t without challenges. It faces competition not only from Ross but from the off-price units of big retailers, such as Nordstrom Rack and Macy’s Backstage. TJX also is dealing with rising labor and freight costs of late.

Also, if conventional department stores decide to hike their discounts on brand-name products at their regular locations, it could narrow the price gap between them and TJX and “give consumers less of a reason to go across to a T.J. Maxx or Marshalls to paw through the racks,” Morris said. “Yes, it’s a treasure hunt, but it’s also an effort.”

The Trump administration’s tariffs on Chinese imports of apparel and other goods could pinch TJX’s profit margins. But Morris said the tariff dispute might benefit TJX.

With the White House threatening to raise the tariffs to 25 percent from 10 percent Jan. 1 if a trade deal isn’t reached, vendors and full-price department stores “have loaded up on goods” from China to protect themselves from the possible increase, Morris said.

But after the holidays, it’s likely those stores will have excess inventory they need to sell quickly ahead of the spring, and TJX “is going to be in a position to go in and buy those products,” he said.

TJX expects to keep growing in popularity. “We see an excellent opportunity to grow our store base to a total of 6,100 stores,” Herrman told analysts last month, which would be a 50 percent increase.