JavaScript class implementation