A mole is defined as a no. which is equal to Avogadro no. 6.022 x 1023 which is used to count any microscopic particle, whether atom, molecules, or electrons etc.
So, 1 mole = 6.022 x 1023 atoms or 6.022 x 1023 molecules or 6.022 x 1023 ions or 6.022 x 1023 electrons/protons/neutrons etc.
In case of NaCl;
Molar mass = 23+ 35.5 = 58.5 gm
No. of moles of NaCl = given mass / molar mass, = 50 gm/ 58.5 gm = 0.85 moles
So, no. of NaCl molecules = moles x Avogadro no. = 0.85 x 6.022 x 1023 = 5.11 x 1023