In chemistry, what is the primary function of a buffer solution?
A) To prevent a solution from changing color when exposed to light
B) To maintain a relatively constant pH despite the addition of small amounts of acids or bases
C) To enhance the rate of a chemical reaction
D) To dissolve a solid into a liquid more effectively