When your project needs a transistor, there are tons of choices. Which makes answering the question “Which transistor should I use or buy?” a daunting task. Fear not, before wading through spec sheet after spec sheet, consider one of these four general purpose transistors. Every electronics enginerd’s toolbox should have a few of each.
Transistors are one of the most versatile discrete components in electronics. In digital circuits, they switch on and off while in analog circuits they are used to amplify signals. For most projects, they are used to turn on a load that would kill the I/O pin of a microcontroller or microprocessor. For most circuits either a BJT or MOSFET can be used, depending on the load current you need to switch.
Here are some more details on each of these.