Taking a swing “at everything” is not unheard of at this age. However, if it is allowed to continue it will cause problems in other areas. It sounds like she does this rather than using her words, and that she does it both when she is happy and sad. How is her verbal development? Does this action usually have words attached to it?
If you have not already, visit with her pediatrician about her behavior and your concerns. We always encourage parents of young children to visit with their children’s doctor to rule out a medical reason for a child’s behavior. Meanwhile, when she lashes out or tries to pull her hair, take hold of her hands and use words to describe a feeling she is probably feeling at that time. This will help her relate her feelings to words rather than actions. The goal is to help her develop the habit of using words instead of physical actions.