it's an ionic compund, that means it is formed by donating or gaining electrons
Na is writen first than, it must be electropositive i.e it has donated electons which made it positive and the clorine gains electron so it's electronegative.
Na is positive because as we know it's atomic number is 11 that means it has 11 protons and 11 electrons now, when it donate electon it has, greater number of protons whose change is +ve so the atom becomes overall positively charged ion or cation.
and something same happens in clorine and because it gains one electron and the number of electrons increase in it by 1 whise charge is -ve so, the atom becomes negatively charged ion or anion which has a -1 charge.