In more detail
A linear (1D) barcode encodes data in the widths of its bars and spaces, read along one line. Retail codes UPC-A (12 digits) and EAN-13 (13 digits) carry only numbers and end in a check digit; Code 128 encodes all 128 ASCII characters and is common on shipping labels; Code 39 is an older alphanumeric code used in industry. A quiet zone of blank space on each side is part of the symbol.
Why it matters
The check digit lets a scanner reject a misread instead of ringing up the wrong product, so a code with a wrong last digit will not scan. Printing too small, too low in contrast (red bars are invisible to many red-light scanners) or without the quiet zone also causes failures. Retail numbers are assigned by GS1, so you cannot simply invent one for products sold in shops.
Example
The EAN-13 check digit for 590123412345: weight the digits alternately 1 and 3 from the left, so 5 + 27 + 0 + 3 + 2 + 9 + 4 + 3 + 2 + 9 + 4 + 15 = 83. The check digit brings this up to the next multiple of 10: 90 − 83 = 7, giving 5901234123457.
Common confusion
A barcode is one-dimensional; a QR code is a two-dimensional code that holds far more data.