For any retail product, the packaging is usually the best place to find out which batteries are necessary. If there is no packaging, generally, the device itself has some markings that indicate what size and type of battery the device requires.
Generally, battery size is obvious as there is only enough space to house the correct size battery, but this does not hold true for all devices. For instance, watch batteries and other small devices that use the small flat batteries can hold various batteries of similar sizes. For these devices, it is best to bring the old battery with you when buying a new one.
Some devices do not use standard batteries but instead use battery packs. This is often the case with RC cars, tools, phones, computers and other "high-tech" devices. For these types of devices, it is always best to use the type of battery pack the manufacture recommends. In this situation, it is helpful to research the device by running a Web search, then going to the manufacturer or distributor's website to download the product's guide/manual. The guide or manual usually explains which batteries are appropriate for the device. Oftentimes when a device uses a battery pack, the manufacturer sells replacement battery packs or provides information on where to purchase the recommended battery pack.