Begining around 8-12 years, children change from being undaunted optimists. It is during this period that they are first able to distinguish between ability and effort, and that distinction can change the attributions they make. Some children, according to Dweck, are mastery oriented, as they attribute their successes to their high ability and their failures to events outside of themselves. These children will persist in spite of failures, because the failures have nothing to do with them really. Failure isn't about their ability.
Failure is about something else.
Not all children are mastery oriented. Some children have what is called the learned helplessness orientation. They believe that failures are due to stable internal causes, so they think that when they fail it is due to their lack of ability. And if they fail, they think of themselves as failures. Meanwhile, their idea of success is that it occurs only as a matter of luck or hard work.