Combine Javascript classes on the fly