An ionic compound is a compound that contains positively charged ions and negatively charged ions.
We can often tell whether a compound is ionic (consisting of ions) or molecular (consisting of molecules) from its composition.
In general, cations are metal ions; anions are nonmetal ions.
Consequently, ionic compounds are generally combinations of metals and nonmetals, as in NaCl. In contrast, molecular compounds are generally composed of nonmetals only, as in H2O.