Hydrogen shows two oxidation states such as +1 and -1
The oxidation state of oxygen is depend on the electronegativity of atom which is bonded to hydrogen atom
for example 1. NaH : electronegativity of H (2.1) is greater than that of Na (0.9) atom therefore here the Oxidation number of hydrogen is -1.
2. HCl : in this case Cl is more electronegative than H therefore here the Oxidation number of Chlorine is -1 and hydrogen is +1
3. Borane (B2H6) : in this case again H (2.1) is more electronegative than B (2) therefore here the Oxidation number of hydrogen is -1.