I have a question about electrolysis. How do we know what will be on anode and cathode if we have for example NaCl diluted in water. How do we know if it's gonna be Na+ or H+??
It depends on its oxidation/reduction potentials. For example, in the electrolysis of a NaCl solution (in water), the reduction potential of water to H2 is -0.83 V while the reduction potential for Na+ to Na is -2.71 V. As the potential for water is greater, water will be reduced instead Na+. Another example, a solution of CuSO4 in water, the potential reduction for Cu2+ to Cu is +0.34 V, greater than the -0.83 V for water, so the Cu2+ will be reduced.