Atoms generally do not exist in free state. They combine with each other to form a stable unit of matter called molecule. The atoms combine by either exchanging or sharing their electrons in their outermost shell forming chemically bonded molecules. When exchange of electrons is involved, the chemical bond is called 'ionic bond' and if electrons are shared between atoms, the bond is known as 'covalent bond'. When bonds are formed, each atom tries to acquire a noble -gas configurations that is stable and hence at lowest energy state. These noble gas elements are Helium, Neon, Argon, Krypton, Xenon, and Radon. They are known as noble gases or inert gases because they do not react with other elements to form compounds. In other words, inert gases do not form chemical bonds. We know that only the outermost electrons or the valence electrons of an atom can take part in a chemical reaction. Since the noble gases are chemically unreactive, we must conclude that the electron arrangements in their atoms are very stable which do not allow the outermost electrons to take part in chemical reactions.
The outermost electron shell of an atom is known as valence shell. The electrons present in the outermost shell of an atom are known as valence electrons because they decide the valency (combining capacity of the atom).
Only the valence electrons of an atom can take part in chemical reactions because they have more energy than all the inner electrons of the atom. We can say that the electrons in the outer shell determine the chemical properties of the atoms.
IONIC BONDS:
An ionic bond is a chemical bond formed by the electrostatic attraction between positive and negative ions. The bond forms between two atoms when one or more electrons are transferred from the valence shell of one atom to the other. The atom that loses electrons becomes a cation (positive ion) and the atom that gains electrons becomes an anion (negative ion).
Any given ion tends to attract as many neighboring ions of opposite charge as possible. When large number of ions gather, they form an ionic solid. The solid normally has a regular crystalline structure that allows for the maximum attraction of ions, given their particular sizes.
In order to understand why ionic bonding occurs, consider the transfer of a valence electron from a sodium atom to the valence shell of a chlorine atom. Based on the electronic configurations for each element, the electron transfer can be represented by the following equation.
Because of the electron transfer, ions are formed acquiring noble gas configurations. The sodium atom has lost one electron from its 3s subshell and has taken on the neon configuration (Ne). The chlorine atom has accepted the electron into its 3p subshell and has taken on the argon configuration. Such noble-gas configurations are very much stable which is why a sodium chloride crystal is formed.
LEWIS ELECTRON DOT SYMBOLS:
One can simplify the preceding equation for the electron transfer between Na and Cl atoms by writing Lewis electron dot symbols. It is a symbol in which the electrons in the valence shell of an atom or ion are represented by dots placed around the letter symbol of the element. The dots are placed one to each side of a letter symbol until all the four sides are occupied. Then the dots are written two to a side until all the valence electrons are accounted for. The exact placement of single dots is immaterial.
The equation representing the transfer of electron from the sodium atom to the chlorine atom can be represented as

The noble- gas configurations of the ions are apparent from the symbols. No dots are shown for the cation (Na) while eight dots are shown for the anion (Cl).
An electron dot structure is a convenient way to represent the valence shell. Valence electrons are shown as dots placed on the sides, top, or bottom of the symbol for the element. It does not matter on which of the four sides you place the dots. However, 1 to 4 valence electrons are usually arranged as single dots. When there are more than 4 electrons, the electrons begin to pair up (are placed in pairs).
If atoms come together and bond, there should be net decrease in energy, because the bonded state should be more stable, and therefore at a lower energy level, compared to when the atoms are free. In the case of ionic bond between sodium atom and chlorine atom, removing a valence electron from the sodium atom requires an energy of 496kJ / mol while adding an electron to the chlorine atom releases an energy of 349kJ / mol. The net bond energy, when sodium chloride crystal is formed is of the order of 147 kJ (496 - 349).
Most of the metals are formed through ionic bonds.
COVALENT BONDS:
Covalent bonds are formed through sharing of valence electrons between two or more atoms and each atom attains stable noble-gas configuration. Consider, for example, the formation of covalent bond between two H atoms to give H2 molecule. As the atoms approach one another, their 1s electrons begin to overlap. Each electron can then occupy a space around both the atoms. In other words, two electrons can be shared by the atoms. The electrons are attracted simultaneously by the positive charges of the two hydrogen nuclei. This attraction that bonds the electrons to both the nuclei is force holding the atoms together.
It is interesting to see how the potential energy of the atoms changes as they approach and bond. As the atoms approach closer and closer their potential energy is lowered. Eventually when the atoms reach a critical separation distance, the repulsion of positive charges on their nuclei becomes stronger than the force of attraction. The minimum distance of approach at which the potential energy of the bonded atoms is lowest is known as the bond length.
Now, we can imagine the reverse process. We start with H2 molecule at normal bond length and energy is needed to separate the two atoms from the molecule. The energy that must be added to the molecule to separate it into individual atoms is known as bond dissociation energy. Larger this dissociation energy stronger is the bond.
The formation of H2 through covalent bond can be represented using Lewis electronic dot formula as shown below:

It may be noted that the two electrons participating in the bond spend part of the time in the region of each atom. In this sense, each atom in H2 has a helium (noble -gas) configuration which can be shown by drawing circles around each atom as shown.

The formation of a covalent bond between hydrogen and chlorine atoms can be represented in a similar way.

The following table gives the electronic configurations of the noble gas elements.

From the above table, it can be observed only one inert gas, helium, has 2 electrons in its outermost shell. All other inert gases have 8 electrons in the outermost shells of their atoms. To have 8 electrons (or 2 electrons) in the outermost shells, is considered the most stable arrangement of electrons and these elements are considered noble and unreactive.
An atom with 2 electrons in the outermost shell gives stability only when the outermost shell is the first (K Shell) and no other shells are present in the atom. An atom with 8 electrons in the outermost shell is known as "octet" of electrons and this type of configuration is called "Octet Configuration".
It is not possible to remove or add electrons in the case of the noble gases. This makes them very stable and unreactive towards chemical reactions (formation of compounds). The other elements tend to combine with other elements to form a compound. In most of the compounds formed by the other elements, each atom has a noble- gas arrangement or octet configuration.