You're not alone if you're in the red in the stock market this year. Losses have piled up as equities have had about as bad a year as we've seen in the past decade. However, the best way to erase these losses isn't to sell stocks. Rather, it is to hold on for dear life.

Quality stocks and a long time horizon never fail to make investors richer. Let's examine two stocks worth keeping in this challenging market and beyond: Abbott Laboratories (ABT -0.59%) and Apple (AAPL -0.57%). These longtime winners can still deliver market-beating returns, despite being down this year. 

ABT Chart.

ABT data by YCharts.

1. Abbott Laboratories

Abbott Laboratories focuses on medical devices, although it has a diversified business with multiple segments that allow it to navigate difficult times. For instance, when the company's medical devices segment took a hit during the pandemic, its diagnostics unit picked up the slack. The company developed and marketed several successful coronavirus diagnostics tests.

When Abbott's nutrition segment was under the weather earlier this year -- specifically, its infant formula products -- the rest of its business still managed a solid performance. Still, Abbott's best long-term prospects arguably lie within medical devices. One key product it can count on is the FreeStyle Libre, a continuous glucose monitoring (CGM) system that helps diabetes patients track their blood glucose levels.

Abbott Laboratories continues to show the benefits of this innovative device. In a recent study with type-2 diabetes patients on once-daily insulin therapy, the FreeStyle Libre reduced the number of hospitalizations associated with acute diabetes events by 67%. The prevalence of diabetes is on the rise. Devices like the FreeStyle Libre that improve the health outcomes of diabetes patients will be in even higher demand in the years to come.

Abbott Laboratories boasts many other devices that could help spearhead growth. Earlier this month, it reported encouraging results from a study for its Amplatzer Piccolo Occluder, a device that treats a heart defect in infants. In another encouraging result, Abbott's HeartMate 3 heart pump recently proved able to extend the life of advanced heart failure patients by at least five years.

Abbott Laboratories has a long history of developing innovative products, typically protected by patents. The healthcare company has built a solid reputation as one of the top medical device players. That grants Abbott a strong and almost impenetrable competitive edge -- a necessary condition for a corporation to be successful over several decades.

That's why getting in on Abbott Laboratories while its shares are down would be a great move. 

2. Apple 

Apple needs no introduction. The company boasts one of the most valuable brands in the world, which grants it solid name recognition and, of course, a competitive edge. But Apple has built this reputation for a reason; the company's products, particularly its iPhones, remain some of the best around. 

Apple recently unveiled a new set of products, including various versions of the iPhone 14. And early data strongly suggests that pre-orders for this new device are robust, coming ahead of what many had predicted. Consider that we are still dealing with challenging economic conditions. Does anyone really need a new iPhone?

The fact that Apple's latest devices are attracting more attention than initially predicted in this environment is impressive -- and it is a testament to the company's brand and customer loyalty. 

Detractors have been preaching the iPhone's fall from grace for several years. It is true that it no longer generates the buzz it did in the late 2000s. Still, the prophecies of doom have yet to pass. And whenever they do actualize (likely not anytime soon, in my view), Apple will be ready. 

The company's services segment, including iCloud, Apple Music, and Apple TV+, continues to grow. As Apple expands its installed base of customers by selling more devices to new users, its ecosystem will become even stronger. The tech giant's services segment also carries higher margins, and that's obviously good for the bottom line.

The lasting dominance of Apple's hardware products, particularly the iPhone, its booming services unit, and the company's solid moat should help it deliver solid returns for a long time, even with a market cap already above $2 trillion.