We first meet Joshua just after Moses struck the rock in obedience and water came out in Exodus 17. Straight after that is the story the Amalekites, descendants of Esau who lived on the edges of what would later be the borders of Israel, attacked the Israelites. Moses gave Joshua responsibility to choose some men and go out and fight the Amalekites (Ex 17:9)