Would like to extend a class in javascript in a practical way?