B cells work in a way similar to T cells, by identifying and fighting specific invading pathogens. B cells produce pathogen-specific antibodies that bind to special B cell receptors on the target antigens' membranes.
B cells are produced in the bone marrow and migrate to the spleen during their development, where they wait for activation by the immune system. Each B cell is able to secrete a specific antibody that works to disable a single type of invading microorganism. When the immune system identifies a pathogen and transports samples of it to the spleen, the particular B cell equipped to fight it begins the process of cell division to build up a population of pathogen-specific immune cells. Most of the new B cells enter the bloodstream and secrete their unique antibody, which circulates throughout the body and disables the hostile organism. Others, known as "memory cells" remain in the spleen. Their role is to retain the latent capacity for fighting off the specific pathogen they've been exposed to. This ensures that a second exposure to the same virus triggers a rapid immune reaction and greatly reduces the amount of time a second infection has to get established before a targeted antibody response is launched against it.