Hey there!
Example:
Sodium Chloride- chlorine has 7 electrons in its valance shell, electronic confrugation being (2,8,7) and sodium has 1 electron in its valance shell EC for sodium is (2,8,1) Hence 1 electron from sodium is transferred to valance shell of chlorine full filling its octet and as sodium losses a electron, its 2nd shell has fullfilled octet rule.
Eight electrons i.e.octet must be complete in valance shell of a atom after its bonding.