A dog's territory: When a dog is sufficiently sure of himself, he will get rid of a threat that comes near him or his pack and it is a better option for some than to stay still or take off running. Normally though, this type of behavior only occurs within their territory, such as in the garden, at the front door of the, behind the gate etc. This is after one spot where the dog has more of a chance at winning. If a dog runs into a stranger that has been brave enough to trespass into his territory, just like humans, he will probably feel less sure of himself about how to handle the situation.
Don't take another step: When a dog sees that his territory is under threat, he shows a brave and protective behavior. A dog will do this by coming near the door and barking excessively. However, a dog's tail and ears will show what he is actually feeling; if his ears are back and glued to his head, his tail is downwards, his body leaning mostly on his hind legs shows that he is ready to run off if necessary. An unsure dog will not show his teeth to not add on to not provoke the other. And most likely his barking is done to get help from other members of his pack to help him.
Unconfident: When a dog feels threatened by a human inside his territory and if he has decided that he is not capable of maintaining his position, he will withdraw at a safe distance. He will try to get away as quickly as possible so that the stranger does not get near him. If a dog feels very threatened by a human being he would probably take off very quickly while at the same time looking over his shoulder to see if he can change strategies if necessary.