1

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 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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().

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.