I'm sure you've watched a movie or TV show where a character is getting ready to open a door, and you just know that the killer is waiting for her. You scream, "No, no, don't open that door!"
How do you know something the character doesn't? Part of that is foreshadowing. The filmmaker has given you clues that the character doesn't have.
For a written story, an author doesn't have the luxury of using spooky music or atmospheric lighting, but she does have other tricks to give the reader the same sense of something lurking behind that closed door.
The simplest way to do this is to have more than one viewpoint in your story. For example, one character learns that the killer is going after your heroine, then when you switch to the heroine's viewpoint, the reader will be expecting something bad to happen.
You can also write from the bad guy’s viewpoint to warn the reader what he’s up to.
Another way is to embed a clue that the heroine sees but doesn't recognize as important because she's learning so much and being menaced at the same time. The reader will often pick up on the clue and recognize the danger.
A third way is to have your character more ignorant or innocent than the reader. A child may misunderstand a situation an adult would recognize as dangerous, and the person who refuses to believe a psychopath or monster is lurking will be easy prey in the reader's eyes.
A fourth way is a subtle use of language. Stephen King is a master of giving the reader the creeps when nothing appears to be happening but soon will. I recommend his ON WRITING which should be in your local library for more on the subject.
A fifth way is genre expectations. In a horror novel, the reader is expecting that scare so it takes almost nothing to make her tense as the character opens that door in the empty house that may be the killer's hiding place.
A common use of genre expectations is to set up a scary situation then let it fizzle, and the moment the character and the reader let their guard down, the killer makes his move.
Foreshadowing doesn't have to be about unhappy or dangerous things to come. You can as easily foreshadow happy events. The square shape in the hero's tuxedo jacket pocket may be a diamond engagement ring box, and he and the heroine are dining at a very nice restaurant, after all, so you and the heroine may be guessing which way the meal will end.
As an author, you must lay down the clues so the reader will think the worse or best of coming events.