Smart JavaScript classes