While the stock market flirts with all-time highs, many tech investors are wondering if Apple (NASDAQ:AAPL) -- the most valuable tech stock in the world -- is still worth buying after its 44% rally over the past twelve months. More importantly, they're probably wondering if Apple can survive a market crash of the magnitude of the dot-com crash of 2000 or the financial meltdown of 2008. Here are some thoughts to consider.

Price performance during previous crashes
The first thing to should do is to check how long it took for Apple to bounce back during previous crises.

After Steve Jobs returned to Apple in July 1997, the company's stock soared from around $0.50 per share to around $5 by March 2000, split-adjusted. While some of that growth was attributed to the introduction of the iMac, most of it was caused by an irrational investor obsession with all tech and Internet-related stocks. That euphoria caused Apple's trailing P/E ratio to soar well over 360 in the late 1990s.

When the industrywide bubble burst, Apple crashed to around $1 by the end of 2000. Many investors at the time gave up on Apple and most tech stocks. However, if investors had rode out the volatility, used dollar-cost averaging, and had faith in Jobs' long-term vision for the company, they would have seen their shares return to $5 by late 2004, thanks to by the launch of the iPod and iTunes. 

Source: Ycharts.

The financial meltdown of 2009 took Apple down from a high of $28.55 in December 2007 to a low of $11.76 by January 2009. This time around, the crash was caused by a marketwide panic rather than valuation concerns for the tech sector. At the bottom of that slide, Apple's P/E plunged from the mid 40s to 10.9. Although the stock became incredibly cheap from a historical perspective, many investors sold the stock or were too afraid to go long. 

Source: Ycharts.

Today, Apple trades at a low 16 times trailing earnings as its price flirts with all-time highs. 

Luxury appeal insulates Apple during downturns
The second factor to consider is how much Apple's core market will be affected by an economic downturn. During recessions, demand for high-end brands like Tiffany, BMW, and Apple often suffer less than comparable mid-range brands, thanks to more affluent consumers retaining more spending power. For example, let's take a look at Apple's iPhone full-year shipments between 2007 and 2014:

Source: Compiled by author from Apple quarterly/annual reports.

You'll notice that demand for the iPhone, the priciest mainstream smartphone on the market, rose throughout the entire crisis. Now compare that chart to the Thomson Reuters/University of Michigan's U.S. Consumer Sentiment benchmark from that same period, which suggests that consumer confidence still hasn't fully recovered to its pre-crisis levels:

Source: Thomson Reuters/University of Michigan.

This could indicate that the iPhone, which generates over half of Apple's revenue, is highly resilient during downturns in consumer sentiment and spending. Apple's brand loyalty is also unmatched among smartphone manufacturers -- a recent Morgan Stanley survey revealed that a whopping 90% of iPhone users would stick with the brand while upgrading, compared to 77% of Samsung (OTC:SSNLF) customers.

The one thing everyone's worried about
In my opinion, the only way that Apple stock could crash and not recover is if iPhone sales peak and fall dramatically during the decline. That would indicate that its biggest growth engine has broken down.

Therefore, Apple needs to diversify its top line with other products beyond the iPhone, iPad, and Mac, which together accounted for nearly 85% of its revenue last quarter. That's why Apple will launch its first smartwatch next year, which will complement the iPhone as an iOS-exclusive device. Wall Street is fairly bullish on the Apple Watch's chances at success -- Morgan Stanley's Katy Huberty, for example, expects Apple to ship as many as 60 million watches within the first year. If that happens, the Apple Watch could easily become a meaningful source of revenue for the company.

Simply put, Apple could survive a market crash relatively insulated.  Further, Apple still offers a nice dividend yield of 1.8% (which only gets bigger if the price falls) for patient investors to wait out future crises.