Clearly, color quantization is a lossy process. It turns out that for most images, the details of the color quantization algorithm have �much� more impact on the final image quality than do any errors introduced by JPEG itself (except at the very lowest JPEG quality settings). Making a good color quantization algorithm is a black art, and no single algorithm is best for all images.
Since JPEG is a full-color format, converting a color JPEG image for display on 8-bit-or-less hardware requires color quantization. The speed and image quality of a JPEG viewer running on such hardware are largely determined by its quantization algorithm. You'll see great variation in image quality among viewers on 8-bit displays, much more than occurs on 24-bit displays.
On the other hand, a GIF image has already been quantized to 256 or fewer colors. (A GIF does have a specific number of colors in its palette, and the format doesn't allow more than 256 palette entries.) GIF has the advantage that the image maker precomputes the color quantization, so viewers don't have to; this is one of the things that make GIF viewers faster than JPEG viewers. But this is also the disadvantages of GIF: you're stuck with the maker's quantization. If the maker quantized to a different number of colors than what you can display, you'll either waste display capability or have to quantize again to further reduce the number of colors (which results in much poorer image quality than if you had quantized once from a full-color image). Furthermore, if the maker didn't use a high-quality color quantization algorithm, you're out of luck -- the image is ruined.
For this reason, JPEG promises significantly better image quality than GIF for all users whose machines don't match the image maker's display hardware. JPEG's full color image can be quantized to precisely match the viewer's display hardware. Furthermore, you will be able to take advantage of future improvements in quantization algorithms (there is a lot of active research in this area), or purchase better display hardware, to get a better view of JPEG images you already have. With a GIF, you're stuck forevermore with what was sent.
A growing number of people have better-than-8-bit display hardware already: 15-bit "hi-color" PC displays, true 24-bit displays on workstations and Macintoshes, etc. For these people, GIF is already obsolete, as it cannot represent an image to the full capabilities of their display. JPEG images can drive these displays much more effectively. In short, JPEG is an all-around better choice than GIF for representing photographic images in a machine-independent fashion.