I wrote a web application using ASP .Net MVC. One of the application's function is to return a list of objects, using json, to the webpage. However these objects are of different types. How can I determine the types of these objects using javascript?
+2
A:
There is no notion of object type in javascript. If you need that information for some kind of logic running client-side, then add a property returning type name to your objects, then check it in JS.
Michał Chaniewski
2009-06-24 11:14:49
A:
You can emit the type of the object within the json serialization on the ASP.NET / server side. But I guess you are using the standard json serializer, and I am not sure if it is tweakable to emit the output of instance.GetType().
Cheeso
2009-06-24 11:18:29