We are all aware, (at least I think we are), that plants produce nectar in their flowers to attract pollinators. These are usually insects, though some plant species use birds or other animals.
The glands which produce it are called nectaries. They are surrounded by a beautifully engineered arrangement of petals, designed to ensure that only those capable of carrying pollen to other flowers can reach the nectar - and then only if they align themselves just as the flower requires. (Flowers are bossier than you'd think!)
This means that the pollinator body-part, which gets dusted with pollen in one flower, will then be correctly positioned to deliver it to the appropriate bit of the next one. It has to be deposited on the stigma, to do the job of fertilising the flower’s future seeds.
Somewhat less known, however, is that plants have other nectaries which are open to all comers. They are called “extra-floral” nectaries - “extra” as in Latin for “outside”.
They can be on various parts of the plant, but a common position is at the base of the leaf. Croton species provide a good example, with their little glands visible to the naked eye (provided it has good eyesight, or has its specs on). Here they are on Croton phebalioides...
...and here on Croton insularis.
Such an easily accessible source of highly nutritious nectar could be found by all sorts of tiny creatures, but a common result is that the fiercest will discover it and keep it for themselves, chasing away (or eating) potential rivals. In this way, the plant attracts protectors, usually ants, which help to keep it safe from other little sap-sucking, leaf-biting creatures.
Isn't that just so knacky?