Barcodes are a machine-readable way of writing letters and numbers. A lase is shone onto the barcode and the reflected light can be interpreted by the barcode reader. There are many types of barcodes, but the ones most commonly found in supermarkets use a row of lines of different widths.
The difeerent widths represent different numbers. In the UK many items are coded with a GTIN-Global Trade Item Number. This allows the manufacturer to print the barcode on the packages which can then be read in many different shops. The numbers are unique to that item.
The barcode only has a number, but no product information. That is held in a database which the retailer can access at the point of sale. It also means that shops can set their own prices and change them easily without re-labelling every item on the shelves.