Theory:

You have seen how metals react with a variety of chemicals in the activities above. What causes metals to react the way they do? Let us review what we have learnt in Class IX about the electronic configuration of elements. Noble gases, which have a completely filled valence shell, have little chemical activity. As a result, we describe element reactivity as a tendency to obtain a completely filled valence shell.
 
Consider the electronic configuration of noble gases, as well as various metals and non-metals.
 
Type of element
Element
Symbol
Atomic number
Number of electrons in shells
K       L       M       N
Noble gases
Helium
Neon
Argon
\(He\)
\(Ne\)
\(Ar\)
\(2\)
\(10\)
\(18\)
\(2\)    
\(2\)        \(8\)
\(2\)        \(8\)        \(8\)
Metals
Sodium
Magnesium
Aluminium
Potassium
Calcium
\(Na\)
\(Mg\)
\(Al\)
\(K\)
\(Ca\)
\(11\)
\(12\)
\(13\)
\(19\)
\(20\)
\(2\)        \(8\)        \(1\)
\(2\)        \(8\)        \(2\)
\(2\)        \(8\)        \(3\)
\(2\)        \(8\)        \(8\)        \(1\)
\(2\)        \(8\)        \(8\)        \(2\)
Non-metals
Nitrogen
Oxygen
Fluorine
Phosphorus
Sulphur
Chlorine
\(N\)
\(O\)
\(F\)
\(P\)
\(S\)
\(Cl\)
\(7\)
\(8\)
\(9\)
\(15\)
\(16\)
\(17\)
\(2\)        \(5\)
\(2\)        \(6\)
\(2\)        \(7\)
\(2\)        \(8\)        \(5\)
\(2\)        \(8\)        \(6\)
\(2\)        \(8\)        \(7\)
 
A sodium atom has one electron in its outermost shell, as shown in the table. Its L shell becomes the outermost shell and has a stable octet if it loses one electron from its M shell. The nucleus of this atom still retains \(11\) protons, but the number of electrons has dropped to \(10\), resulting in a net positive charge, leading to the sodium cation \(Na^+\). On the other hand, chlorine contains seven electrons in its outermost shell.
 
Sodium atom
Chlorine atom
 
Electrons present = \(11\)
\( \)
Electronic configuration = (\(2, 8, 1\))
 
shutterstock_1933388447.jpg
 
Electrons present = \(17\)

Electronic configuration = (\(2, 8, 7\))
 
shutterstock_1933444490.jpg

Where, sodium will donate \(1\) electron to the chlorine atom to complete their respective octets. In this way, the molecule sodium chloride (\(NaCl\)), an ionic compound will form.
 
The reaction is as shown below:
 
NaNa++e2,8,12,8SodiumcationCl+eCl2,8,72,8,8ChlorineanionNa++ClNaClSodiumchloride
 
Capture3.JPG
Sodium chloride formation
 
Since sodium and chloride ions have opposite charges, they attract one other and are held together by strong electrostatic forces to form sodium chloride (\(NaCl\)). We should note that sodium chloride does not exist as molecules but aggregates of oppositely charged ions.
Common salt (\(NaCl\)) is an ionic compound that conducts electricity only in a molten state. In a molten state, the electrostatic forces of attraction between oppositely charged ions (\(Na^+\) and \(Cl^–\)) are overcome due to heat. Hence, the ions move freely and conduct electricity.
Let's look at another example of ionic compound formation, magnesium chloride.
 
Magnesium atom
Chlorine atom
 
Electrons present = \(12\)
 
Electronic configuration = (\(2, 8, 2\)) 
 
shutterstock_1933397057.jpg
 
Electrons present = \(17\)

Electronic configuration = (\(2, 8, 7\))
 
shutterstock_1933444490.jpg
 
The reaction is shown below:
 
MgMg2++2e2,8,22,8MagnesiumcationCl+eCl2,8,72,8,8ChlorineanionMg2++2ClMgCl2Magnesiumchloride
 
CK12 Screenshot 8-6-2.png
\(MgCl_2\) formation
 
Ionic compounds or electrovalent compounds are compounds formed by transferring electrons from a metal to a non-metal in this way.
Are you able to identify the cation and anion in \(MgCl_2\)?
  
The answer for this question is "yes".
 
An anion is a negatively charged atom or molecule, while a cation is a positively charged atom or molecule. Thus, \(Mg^{2+}\) is known as cation and \(Cl^-\) is known as anion.
Reference:
https://chem.libretexts.org/@api/deki/files/78198/CK12_Screenshot_8-6-2.png?revision=1&size=bestfit&width=262&height=126
https://upload.wikimedia.org/wikipedia/commons/0/0c/IonicBondingRH11.png