As always though I research the topic a little in case I find a really useful guide or interpretation of the device beforehand. Strangely it was almost impossible to find good definitions or examples of juxtaposition and what it can do for your writing.
As such I feel empowered to give my personal view of it, as I use it and as I like to see it being used, as well as a little background information on why I think it's so effective a tool.
For those who don't know what it is, juxtaposition refers to the act of placing two opposing or contrasting ideas, concepts, words etc, close together, so that extra emphasis can be drawn from their comparison. In art this might involve painting a symbol of death, such as a skull, in a painting about life, for example Boticelli's The Birth of Venus. Even hanging a painting about death next to a painting about life in a gallery is an example of juxtaposition. Someone could even cast Danny DeVito and Arnold Schwarzenegger in a film together, but it probably wouldn't be very good!
In literature, juxtaposition can take two main forms, which I will call thematic and stylistic. Thematic juxtaposition is the term I have given the notion of overall themes, settings, ambience and characters behaviour. So having an ostensibly good guy and markedly bad guy in the same room is a good example. Highlighting themes of life and death throughout the story, or setting a novel in two principle locations which are diametrically opposed, the city and the countryside, a war torn slum and an idyllic beach. This style of juxtaposition is the easiest to identify and the most commonly employed by first time writers, but it's not the one I'm most interested in.
Stylistic juxtaposition works a little more like an oxymoron, but instead of contradicting itself it skilfully remains consistent in tone or message, despite choosing words or phrases that would ordinarily provide conflict, for example light and shade, good and evil, happiness and sadness. You don't always need to be using them in their most literal forms to achieve interesting results.
"This doughnut may be sinful, but it tasted so damned good."
In this example we have the words 'sinful' and even 'damned', right next to the word 'good'.
To understand why this statement can be so impactful, I've done a little introspective thinking and stumbled across what I think makes it work. I believe our brains are attuned to identifying conflict or contradiction in language, which would make sense when you consider our extremely developed ability to lie, something which is nearly unique to humans. Also, we like things to make sense, which is why we look for patterns where there are none, or ignore details that don't fit our preconceived idea of the overall whole.
Consider this sentence:
"I walked slowly away from the man, as quickly as I could."
Reading that sentence should cause a jarring effect on your brain, little alarm bells go off to tell you that something is wrong. You can't walk slowly and quickly at the same time and your brain is attuned to picking up on that and informing you of the conflict, or inconsistency.
Now consider this sentence:
"My heartbeat slowed as I walked quickly away from the man."
This time there's only a minor jarring effect on the brain, enough to emphasise and make you take notice, but not enough to set the full alarm bells ringing. There's no inconsistency or conflict in the language, we understand exactly what is meant, but the mere presence of the contrasting words 'slowed' and 'quickly' is enough to provide extra emphasis.
I won't go into oxymorons here but it's worth noting that the phrase “he was quick to slow down” is a little more oxymoronic as one word is acting directly on the other. All oxymorons will necessarily employ juxtaposition, but not all juxtaposition is strictly oxymoronic. Fun Fact: The word oxymoron is an oxymoron, coming from the Greek for 'sharp, keen' and 'dull, foolish'!
Obviously thematic and stylistic juxtaposition can work well hand in hand. One of the most famous examples I can think of would be the first lines of Charles Dickens' A Tale of Two Cities. Foreshadowing the differences detailed throughout the story between London and Paris, Dickens opens with the immortal words:
"It was the best of times, it was the worst of times..."
Shakespeare, on the other hand, is more subtle with his themes of light and dark in the ultimate play of juxtaposition, Romeo and Juliet.
"O, she doth teach the torches to burn bright!
It seems she hangs upon the cheek of night
Like a rich jewel in an Ethiope’s ear;"
Note there are actually two examples of juxtaposition at play here, one sensory and one sociopolitical. Bonus points if you reveal the latter in the comments section!
So juxtaposition can be used not just in your themes and characters, but in the language you choose for the most mundane of story events. It's probably best not to force it into every sentence, since it will make the book difficult to read, but used sparingly it can add a spark to any segment of prose, elevating it from the mundane to the magical, practical to purposefully poetic.
Feel free to paste your favourite examples of stylistic or thematic juxtaposition in the comment section, somebody ought to use it!