Foreshadowing is a device used in writing to elude to a future event. It is a tool writers use to give a hint about what will happen later in the story. The best way to understand foreshadowing is use universally well known stories as examples.
In the Boy Who Cried Wolf, every time he cried “wolf” to draw the townspeople to his aid, they warned him that one day there would be a real emergency, and no one would help him because they wouldn’t know if he was joking or in real need. In the end, the wolf got the sheep because the boy’s multiple pranks destroyed their trust; thus confirming their fears.
In a horror movie, when the protagonists are frightened by something suddenly jumping out at them that turns out to be a benign object, but later are brutally killed by an axe murderer jumping out at them, the benign object gives the watcher a clue about later happenings in the movie.
The Star Wars saga are absolutely riddled with examples. In Star Wars, when Ben Kenobi tells Luke Skywalker that his father was killed by Darth Vader, he was both eluding to a future conflict and speaking metaphorically about Anaken Skywalker’s “death” and rebirth as Darth Vader. In the Phantom Menace, we see young Anaken’s shadow shaped like Darth Vader’s profile, eluding to his eventual change. For more information on the Star Wars Saga, check out the Lucas Film website.