Foreshadowing can be done through many means: dialogue, character actions, scene descriptions and the titles of chapters or the novel itself.
The function of foreshadowing is to build anticipation in the reader about what might happen next and adds dramatic tension to a story. It adds emphasis to the event when it finally occurs.