I describe the banal thing, data comes to the frontend, and this data needs to be specially processed depending on the type. For example, we have a list with animals, we need to draw it, and if it's a cat, add a picture with a ball. Model example:
var model= { "animals" = [{Id = 1, name ="Murzik", typeId = 1}, {Id = 2, name ="Snezok", typeId = 1}, {Id = 3, name ="Barbos", typeId = 2}], "animalTypes = [{typeId = 1, name="Cat"},{typeId = 2, name="Dog"},{typeId = 3, name="Fish"}] }
If type hardcodes if(typeId = 1)
are probably not an option. But it seems to me that without some kind of hardcode in one form or another can not do without excessive complication. What are the best practices for such simple cases in the world of modern web development?