What are expando objects in javascripts?
For what purpose we need this ? Any complete example will be appreciated
I found 1 article here Javascript: The red-headed stepchild of web development
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, in javascript, any object is an expando object. What it means is, as the article covers, that whenever you try to access a property1 it will automatically be created.
The moment you assign
myPropa value, the propertymyPropis dynamically created, eventhough it didn’t exist before. In a lot of other languages, such as C#, this is not normally possible (actually C# has just enabled expando object support as well, but that’s besides the point). To access a property in a normal class in C#, you need to specify in the class that it does indeed have this property.1 Not quite correct. See npup’s comment below for clarification.