Code-switching often occurs in bilingual communities or families. For example, a family that has recently immigrated to a country where a different language is spoken may switch back and forth between that language and their mother tongue, while they are learning the new language. Also, in communities in, for example, the United States with a large number of Spanish speakers, a sentence might have a mixture of Spanish and English words known as "Spanglish" (a similar situation can occur in communities in Canada with both Francophone and Anglophone populations).
Code-switching also occurs within a particular language. As an extreme example in English, a person would likely not use the same words or phrases when speaking to Queen Elizabeth II as they would use when speaking to their friends in a much less formal atmosphere.