On PC, Left 4 Dead 2 exposes a developer console. First enable it in the options menu under keyboard/mouse settings, then press the tilde key (~) during play to bring it up and type commands.
One important caveat: the console is disabled on official VAC-secured servers. Using it there will get your account banned. Keep it to local games and private servers with cheats explicitly allowed.