To know the number of electrons in an element, one needs to know the atomic number of that element. In neutral atom, the number of protons are equal to number of electrons. Since atomic number is equal to number of protons, hence for neutral atoms it is also equal to number of electrons. However, for a charged species, such as ions, the number of electrons and protons are not equal.
For example:
Sodium, Na
atomic number = 11
number of electrons = 11
while for sodium ion, Na+, formed by loss of one electron.
number of electrons = 10
Chlorine, Cl
atomic number = 17
number of electrons = 17
while for chloride ion, Cl-, formed by gaining one electron.
number of electrons = 18